Can't load existing schemas
I have a bunch of schemas already defined. When I try and load them I keep getting this error:
connection error [TypeError: Undefined type at paths
Did you try nesting Schemas? You can only nest using refs or arrays.]
No clue what this error means. All of my schemas are broken out as individual functions and I have them defined like this:
var UserModel = function(){ _schema = {...} _model = mongoose.model("User", _schema); return { Schema: _schema, Model: _model }; }(); module.exports = UserModel;
And here's my config file: var User = require('./user'), Page = require("./page");
module.exports = { connect: 'mongodb://user:pw@localhost:port/db', User: [User.Schema], Page: [Page.Schema] }
any thoughts on how to fix this problem?
Can you share how you defined your schema? The error suggests a hint to the solution lies there.
Alternatively you could try the following in your config although it really shouldn't matter.
module.exports.connect = 'mongodbConnectionURI';
module.exports.User = require('pathtoUserModel.js).Model;