-
-
Save mcoolin/1239022 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
var maSchema = new Schema({ | |
name: { type: String, default: 'nameless' } | |
, age: { type: Number, default: function () { return 0 }} | |
}); | |
var M = mongoose.model('M', maSchema); | |
// populate some data ... | |
M.findOne({..}, { age: 1 }, function (err, m) { | |
console.log(m.name) // undefined (previously would be "nameless") | |
console.log(m.age) // some value | |
console.log(m._id) // some value | |
}) | |
M.find({..}, { age: 0 }, function (err, docs) { | |
var m = docs[0]; | |
console.log(m.name) // some value | |
console.log(m.age) // undefined (previously would be 0) | |
console.log(m._id) // some value | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment