Closed duard closed 6 years ago
I just comment this 2 attributes because I dont know what is this models/attributes and now it works
/**
* User Schema
*/
const UserSchema = new mongoose.Schema({
email: {
type: String,
unique: true
},
push: {
type: String,
unique: true
},
createdAt: {
type: Date,
default: Date.now
},
role: {
type: String,
enum: ['user', 'agent', 'admin'],
default: 'user'
},
**// location: { type: mongoose.Schema.Types.ObjectId, ref: 'Location' },
// criteria: { type: mongoose.Schema.Types.ObjectId, ref: 'Location' },**
})
Hey, thanks for reporting this! It looks like some legacy references I used to have for an example. I will get a PR up for this soon.
When I try to access /users the app crash
/Users/duard/Development/api-es6/node_modules/mongoose/lib/connection.js:778 throw new MongooseError.MissingSchemaError(name); ^ MongooseError: Schema hasn't been registered for model "Location". Use mongoose.model(name, schema) at NativeConnection.Connection.model (/Users/duard/Development/api-es6/node_modules/mongoose/lib/connection.js:778:11) at getModelsMapForPopulate (/Users/duard/Development/api-es6/node_modules/mongoose/lib/model.js:3040:18) at populate (/Users/duard/Development/api-es6/node_modules/mongoose/lib/model.js:2660:15) at _populate (/Users/duard/Development/api-es6/node_modules/mongoose/lib/model.js:2628:5) at Function.Model.populate (/Users/duard/Development/api-es6/node_modules/mongoose/lib/model.js:2588:5) at Immediate.cb (/Users/duard/Development/api-es6/node_modules/mongoose/lib/query.js:1102:17) at Immediate.<anonymous> (/Users/duard/Development/api-es6/node_modules/mquery/lib/utils.js:137:16) at runCallback (timers.js:781:20) at tryOnImmediate (timers.js:743:5) at processImmediate [as _immediateCallback] (timers.js:714:5) [nodemon] app crashed - waiting for file changes before starting...