1

I need help porting this plugin to Mongoose 5 https://github.com/janez89/mongoose-materialized

The plugin is probably not working due to mpromise being deprecated on Mongoose 5. getting error on running any method using mongoose schema

promise resolver undefined is not a function

However when I try replacing the mongoose.promise, I can't figure out how to plug in the new promise resolver

1 Answers1

0

replace mpromise by global.Promise:

mongoose.Promise=global.Promise

example with mongoose-materialized

var mongoose = require('mongoose'),
    materializedPlugin = require('mongoose-materialized'),
    Schema = mongoose.Schema;


//replace mongoose promise
mongoose.Promise=global.Promise;

mongoose.connect('mongodb://localhost/materialized');

var CatSchema = new Schema({
  name: {type: String}
});


CatSchema.plugin(materializedPlugin);

var Cat= mongoose.model('Cat', CatSchema); // Category
Robot
  • 913
  • 6
  • 8