-
-
Save donnut/3781175 to your computer and use it in GitHub Desktop.
mongoose recursive schema definition that includes a model (successful)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'mongoose' | |
, './Bm' | |
], function( | |
mongoose, | |
Bm | |
) { | |
var A = new mongoose.Schema({ | |
name: String | |
}); | |
return A; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'mongoose' | |
, './A' | |
], function( | |
mongoose, | |
A | |
) { | |
var B = new mongoose.Schema({ | |
name: String | |
}); | |
return B; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'mongoose' | |
, './B' | |
], function( | |
mongoose, | |
B | |
) { | |
return mongoose.model('Bm', B); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var requirejs = require('requirejs') | |
, mongoose = require('mongoose'); | |
requirejs.config({ | |
baseUrl: __dirname | |
, nodeRequire: require | |
}); | |
requirejs([ | |
'./A' | |
, './Bm' | |
], function( | |
A | |
, Bm | |
) { | |
var Am = mongoose.model('A', A); | |
var a = new Am(); | |
var b = new Bm(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment