MissingSchemaError: Schema hasn't been registered for model “User”

前端 未结 16 1113
别跟我提以往
别跟我提以往 2020-12-02 16:56

In my models/user.js file:

var mongoose = require(\'mongoose\');
var Schema = mongoose.Schema;

var userSchema = new Schema({
    (define schema         


        
16条回答
  •  感动是毒
    2020-12-02 17:05

    I encountered this issue when tried to add a new model on the base code of this tutorial User Auth on MEAN stack. The solution is like what Ahei mentioned.

    Specifically, I need to add a line require('path/to/your/model') in the end of /app_api/models/db.js which is required in the app.js. It is better to keep the consistency of the structure for the ease of development.

提交回复
热议问题