kpfromer / Nestjs Typegoose
Licence: mit
Typegoose with NestJS
Stars: β 215
Programming Languages
typescript
32286 projects
Projects that are alternatives of or similar to Nestjs Typegoose
nest-rest-mongo-boilerplate
π± backend with nest (typescript), mongoose, and authentication
Stars: β 180 (-16.28%)
Mutual labels: mongoose, nest, nestjs
Nest User Auth
A starter build for a back end which implements managing users with MongoDB, Mongoose, NestJS, Passport-JWT, and GraphQL.
Stars: β 145 (-32.56%)
Mutual labels: mongoose, nestjs, nest
Mongoose
Mongoose module for Nest framework (node.js) πΈ
Stars: β 191 (-11.16%)
Mutual labels: mongoose, nestjs, nest
angular-chat
Angular v.9, Node.js, Nest.js v.6, Mongoose, Socket.io, Passport, Angular Universal SSR (in progress...)
Stars: β 35 (-83.72%)
Mutual labels: mongoose, nest, nestjs
server-next
π The next generation of RESTful API service and more for Mix Space, powered by @nestjs.
Stars: β 43 (-80%)
Mutual labels: mongoose, nest, nestjs
Nest Angular
NestJS, Angular 6, Server Side Rendering (Angular Universal), GraphQL, JWT (JSON Web Tokens) and Facebook/Twitter/Google Authentication, Mongoose, MongoDB, Webpack, TypeScript
Stars: β 307 (+42.79%)
Mutual labels: mongoose, nestjs, nest
Nodepress
π RESTful API service for Blog/CMS, powered by @nestjs
Stars: β 829 (+285.58%)
Mutual labels: mongoose, nestjs, nest
Nest Cnode
CNode η€ΎεΊ Nest ηζ¬ https://cnodejs.org/
Stars: β 125 (-41.86%)
Mutual labels: mongoose, nestjs
Nest Event
Event handling with decorators for NestJS Framework
Stars: β 128 (-40.47%)
Mutual labels: nestjs, nest
Passport
Passport module for Nest framework (node.js) π
Stars: β 211 (-1.86%)
Mutual labels: nestjs, nest
Serverless Core
Serverless Core module for Nest framework (node.js) π¦
Stars: β 154 (-28.37%)
Mutual labels: nestjs, nest
Nest
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications on top of TypeScript & JavaScript (ES6, ES7, ES8) π
Stars: β 42,981 (+19891.16%)
Mutual labels: nestjs, nest
Sequelize
Sequelize module for Nest framework (node.js) π
Stars: β 88 (-59.07%)
Mutual labels: nestjs, nest
Schedule
Schedule module for Nest framework (node.js) β°
Stars: β 137 (-36.28%)
Mutual labels: nestjs, nest
Simple Todos
A simple web application powered by Nuxt.js π & Nest Framework π»
Stars: β 81 (-62.33%)
Mutual labels: nestjs, nest
Nestjs Roles
Type safe roles guard and decorator made easy
Stars: β 78 (-63.72%)
Mutual labels: nestjs, nest
Throttler
A rate limiting module for NestJS to work with Fastify, Express, GQL, Websockets, and RPC π§
Stars: β 145 (-32.56%)
Mutual labels: nestjs, nest
Config
Configuration module for Nest framework (node.js) π
Stars: β 161 (-25.12%)
Mutual labels: nestjs, nest
Elasticsearch
Elasticsearch module based on the official elasticsearch package πΏ
Stars: β 176 (-18.14%)
Mutual labels: nestjs, nest
nestjs-typegoose
Description
Injects typegoose models for nest components and controllers. Typegoose equivalant for @nestjs/mongoose.
Using Typegoose removes the need for having a Model interface.
Installation
npm install --save nestjs-typegoose
or
yarn add nestjs-typegoose
Documentation
Here is the full documentation describing all basic and advanced features.
Basic usage
You can checkout the example
project for more details.
app.module.ts
import { Module } from "@nestjs/common";
import { TypegooseModule } from "nestjs-typegoose";
import { CatsModule } from "./cat.module.ts";
@Module({
imports: [
TypegooseModule.forRoot("mongodb://localhost:27017/nest", {
useNewUrlParser: true,
}),
CatsModule,
],
})
export class ApplicationModule {}
Create class that describes your schema
cat.model.ts
import { prop } from "@typegoose/typegoose";
import { IsString } from "class-validator";
export class Cat {
@IsString()
@prop({ required: true })
name: string;
}
Inject Cat for CatsModule
cat.module.ts
import { Module } from "@nestjs/common";
import { TypegooseModule } from "nestjs-typegoose";
import { Cat } from "./cat.model";
import { CatsController } from "./cats.controller";
import { CatsService } from "./cats.service";
@Module({
imports: [TypegooseModule.forFeature([Cat])],
controllers: [CatsController],
providers: [CatsService],
})
export class CatsModule {}
Get the cat model in a service
cats.service.ts
import { Injectable } from "@nestjs/common";
import { InjectModel } from "nestjs-typegoose";
import { Cat } from "./cat.model";
import { ReturnModelType } from "@typegoose/typegoose";
@Injectable()
export class CatsService {
constructor(
@InjectModel(Cat) private readonly catModel: ReturnModelType<typeof Cat>
) {}
async create(createCatDto: { name: string }): Promise<Cat> {
const createdCat = new this.catModel(createCatDto);
return await createdCat.save();
}
async findAll(): Promise<Cat[] | null> {
return await this.catModel.find().exec();
}
}
Finally, use the service in a controller!
cats.controller.ts
import { Controller, Get, Post, Body } from "@nestjs/common";
import { CatsService } from "./cats.service";
import { Cat } from "./cats.model.ts";
@Controller("cats")
export class CatsController {
constructor(private readonly catsService: CatsService) {}
@Get()
async getCats(): Promise<Cat[] | null> {
return await this.catsService.findAll();
}
@Post()
async create(@Body() cat: Cat): Promise<Cat> {
return await this.catsService.create(cat);
}
}
Requirements
- @typegoose/typegoose +6.1.5
- @nestjs/common +6.10.1
- @nestjs/core +6.10.1
- mongoose (with typings
@types/mongoose
) +5.7.12
License
nestjs-typegoose is MIT licensed.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].