Getting this very well known warning :
(node:15304) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
The usual fix is to use a Promise library like Bluebird instead :
mongoose.Promise = require('bluebird');
(Edit) or mongoose.Promise = global.Promise
, but according to this post and this post, Bluebird is 4 times faster than ES6's native Promise
However, in Nest, we're not including Mongoose directly. We include Nest's own @nestjs/mongoose
module (which internally, imports Mongoose).
import { MongooseModule } from '@nestjs/mongoose';
@Module({
controllers: [AdsController],
imports: [ MongooseModule.forRoot('mongodb://localhost/nest') ]
})
Therefore mongoose
is undefined so I can't attach Bluebird to it.
How to inject Bluebird in Mongoose when using NestJS?