i'm trying to write a query that chooses the most recently created entry that also has a false value. My schema looks like this:
var EntrySchema = new Schema({
timestamp: {
type: Date,
default: Date.now
},
booth: Number,
used: Boolean,
strip: String,
intro: String,
sess1: String,
sess2: String,
sess3: String,
sess4: String
});
I'm looking to only return ONE entry that has a 'used' key set to false. Any help would be appreciated!
This is what i'm working with now.
Entry.find({used: false}).sort({timestamp:-1}).limit(1).exec(
function (err, entrys) {
if (err) {
return handleError(res, err);
}
return res.json(200, entrys);
}
);