Skip to content

Instantly share code, notes, and snippets.

@pennyfx
Created October 18, 2011 06:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pennyfx/1294757 to your computer and use it in GitHub Desktop.
Save pennyfx/1294757 to your computer and use it in GitHub Desktop.
Mongoose Bug#552
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);
});
@aheckmann
Copy link

thanks! i was able to reproduce finally. taking a look now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment