Created
October 18, 2011 06:35
-
-
Save pennyfx/1294757 to your computer and use it in GitHub Desktop.
Mongoose Bug#552
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 mongoose = module.exports.mongoose = require('mongoose'); | |
var PostSchema = new mongoose.Schema({ | |
title: { | |
type: String | |
}, | |
slug_key: String, | |
body: String, | |
last_activity_at: Date, | |
created_at: { | |
'type': Date, | |
'default': Date.now | |
} | |
}); | |
PostSchema.statics.getBySlug = function(slug, callback) { | |
var Post = mongoose.model('Post'); | |
Post.find({ | |
slub_key: slug | |
}, function(err, result) { | |
callback(err, result); | |
}); | |
}; | |
mongoose.model('Post', PostSchema); | |
var Post = mongoose.Model('Post'); | |
Post.getBySlug('test-slug', function(err, result) { | |
console.log("getBySlug", err, result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks! i was able to reproduce finally. taking a look now