mongooser icon indicating copy to clipboard operation
mongooser copied to clipboard

Can't load existing schemas

Open warnero opened this issue 11 years ago • 1 comments

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?

warnero avatar Apr 02 '14 22:04 warnero

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;

avishaan avatar Jun 21 '14 02:06 avishaan