Skip to content

Instantly share code, notes, and snippets.

@donnut
Created September 25, 2012 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donnut/3781175 to your computer and use it in GitHub Desktop.
Save donnut/3781175 to your computer and use it in GitHub Desktop.
mongoose recursive schema definition that includes a model (successful)
define([
'mongoose'
, './Bm'
], function(
mongoose,
Bm
) {
var A = new mongoose.Schema({
name: String
});
return A;
});
define([
'mongoose'
, './A'
], function(
mongoose,
A
) {
var B = new mongoose.Schema({
name: String
});
return B;
});
define([
'mongoose'
, './B'
], function(
mongoose,
B
) {
return mongoose.model('Bm', B);
});
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