Error registering models after upgrade to mongoose@2.1.2
Opened this issue · 0 comments
lionstone commented
After I upgraded to mongoose 2.1.2, node crashes trying to register models with mongoose-admin:
TypeError: object is not a function
at Schema.CALL_NON_FUNCTION_AS_CONSTRUCTOR (native)
at new SchemaArray (/Users/lionstone/projects/colingo/express/node_modules/mongoose-admin/node_modules/mongoose/lib/schema/array.js:42:19)
at Function.interpretAsType (/Users/lionstone/projects/colingo/express/node_modules/mongoose-admin/node_modules/mongoose/lib/schema.js:201:12)
at Schema.path (/Users/lionstone/projects/colingo/express/node_modules/mongoose-admin/node_modules/mongoose/lib/schema.js:162:29)
at Schema.add (/Users/lionstone/projects/colingo/express/node_modules/mongoose-admin/node_modules/mongoose/lib/schema.js:110:12)
at new Schema (/Users/lionstone/projects/colingo/express/node_modules/mongoose-admin/node_modules/mongoose/lib/schema.js:38:10)
at MongooseAdmin.registerModel (/Users/lionstone/projects/colingo/express/node_modules/mongoose-admin/lib/mongoose-admin.js:110:18)
at Object.<anonymous> (/Users/lionstone/projects/colingo/express/models.js:141:7)
at Module._compile (module.js:402:26)
at Object..js (module.js:408:10)
Error only goes away when I dont register any models
Example code:
var TutorProfileModel = {
username : { type: String, index: true }
, experience : { type: String, default: '' }
, bio : { type: String, default: '' }
, video_url : { type: String, default: '' }
, comments : [TutorCommentSchema]
}
var TutorProfile = new Schema(TutorProfileModel)
mongoose.model('TutorProfile', TutorProfile);
var admin = mongoose_admin.createAdmin('mongodb://localhost/chat', { port : 3001 });
admin.registerModel('TutorProfile', TutorProfileModel, {list:['username','expreience','bio','video_url'], sort:['username']});