-
-
Save donnut/3781153 to your computer and use it in GitHub Desktop.
mongoose recursive schema definition that includes model (fails)
This file contains hidden or 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' | |
| , './Cm' | |
| ], function( | |
| mongoose, | |
| Cm | |
| ) { | |
| var A = new mongoose.Schema({ | |
| name: String | |
| }); | |
| return A; | |
| }); |
This file contains hidden or 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; | |
| });vi |
This file contains hidden or 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 | |
| ) { | |
| var C = new mongoose.Schema({ | |
| name: String | |
| , ref: [B] | |
| }); | |
| return C; | |
| }); |
This file contains hidden or 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' | |
| , './C' | |
| ], function( | |
| mongoose, | |
| C | |
| ) { | |
| return mongoose.model('Cm', C); | |
| }); |
This file contains hidden or 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' | |
| , './Cm' | |
| ], function( | |
| A | |
| , Cm | |
| ) { | |
| var Am = mongoose.model('A', A); | |
| var a = new Am(); | |
| var c = new Cm(); | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
running this in node generates the following error: