GithubHelp home page GithubHelp logo

classicvalues / nestjs-crud-mongoose Goto Github PK

View Code? Open in Web Editor NEW

This project forked from topfullstack/nestjs-crud-mongoose

0.0 1.0 0.0 17 KB

mongoose service adapter for @nestjsx/crud

License: MIT License

TypeScript 100.00%

nestjs-crud-mongoose's Introduction

nestjs-crud-mongoose

Mongoose/Typegoose service adapter for @nestjsx/crud

Nest.js + typegoose video (chinese):

Nest.js + Typegoose 中文视频教程请移步哔哩哔哩全栈之巅:

https://space.bilibili.com/341919508

How to

Install

yarn add nestjs-crud-mongoose
# or
npm i nestjs-crud-mongoose

Create a service based on a mongoose/typegoose model

/src/users/users.service.ts

// for typegoose users
import { User } from "../../common/users/user.model";
import { Injectable, Inject } from "@nestjs/common";
import { ModelType } from "@typegoose/typegoose/lib/types";
import { MongooseCrudService } from "./mongoose-crud.service";

@Injectable()
export class UsersService extends MongooseCrudService<User>{
  constructor(@Inject('UserModel') public model: ModelType<User>) {
    super(model)
  }
}

OR

// for mongoose users
import { User } from "../../common/users/user.model";
import { Injectable, Inject } from "@nestjs/common";
import { Model } from "mongoose";
import { MongooseCrudService } from "./mongoose-crud.service";

@Injectable()
export class UsersService extends MongooseCrudService<User>{
  constructor(@Inject('UserModel') public model: Model<User>) {
    super(model)
  }
}

Inject UsersService to your UsersController:

@Crud({
  // ...
})
export class UsersController {
  constructor(public service: UsersService) { }
}

Thanks to

Related docs

nestjs-crud-mongoose's People

Contributors

wxs77577 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.