tutts / es6-express-mongoose-passport-rest-api

Lightweight boilerplate for Node RESTful API, ES6, Express, Mongoose and Passport 🎁

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

/users crash app

duard opened this issue · comments

When I try to access /users the app crash
screen shot 2017-10-03 at 7 26 14 am

/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...

I just comment this 2 attributes because I dont know what is this models/attributes and now it works
screen shot 2017-10-03 at 7 58 13 am

/**
 * 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.