Created
July 10, 2012 17:08
-
-
Save nooga/3084757 to your computer and use it in GitHub Desktop.
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
/* category.js */ | |
var mongoose = require('mongoose') | |
, Schema = mongoose.Schema | |
, ObjectId = Schema.ObjectId; | |
var Category = new Schema({ | |
... | |
}); | |
Category.statics.foobar = function() { | |
... | |
} | |
module.exports = mongoose.model('Category', Category); | |
/* photo.js */ | |
var mongoose = require('mongoose') | |
, Schema = mongoose.Schema | |
, ObjectId = Schema.ObjectId | |
, Category = require('./category'); //defined here | |
var Photo = new Schema({ | |
... | |
}); | |
Photo.statics.getRandomFromCat = function(category_id, cb) { | |
console.log("getRandomFromCat",category_id); | |
if(category_id) { | |
Category.findById(category_id, function(err, cat) { | |
if(err) throw err; | |
//.... | |
} | |
} else { | |
//.... | |
} | |
}); | |
module.exports = mongoose.model('User', User); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeError: Object function model() {
Model.apply(this, arguments);
} has no method 'getById'