-
-
Save lykmapipo/52d232ee1ee7aaf23661 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 = require('mongoose'); | |
var Schema = mongoose.Schema; | |
mongoose.connect('localhost', 'testing_querybydate'); | |
var schema = new Schema({ | |
created: Date | |
, data: {} | |
}); | |
var A = mongoose.model('A', schema); | |
mongoose.connection.on('open', function () { | |
var a = new A({ created: new Date }); | |
a.save(function (err, a) { | |
if (err) return console.error(err.stack||err); | |
A.find({ created: { $lte: new Date('2012-05-16T20:54:35.630Z') }}, function (err, docs) { | |
if (err) console.error(err.stack||err); | |
console.error('found', docs); | |
mongoose.connection.db.dropDatabase(function () { | |
mongoose.connection.close(); | |
}); | |
}); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment