My problem: give me a list of documents older than X time.
If I have a document created with
db.dates.insert({date: new Date()});
And now I want to find it only when the “date” has become 30 minutes:
db.dates.find({ $where: "this.date.getTime() + 30 * 60000 <= new Date()"});
This works, but the Mongo docs say quite clearly that there is a significant performance hit for $ where the requests are.
So the question is, is there a better way?
========== UPDATE 1 ===========
I should add that I hope that this query function “dynamically” will create a query once and use it to get the tail cursor on a closed collection ... and I'm not sure that this is actually possible.
I will test and rewrite.
========== UPDATE 2 ===========
, , "" , , ", ", , ( db. CPP):
if ( replSettings.slavedelay && ( unsigned( time( 0 ) ) < nextOpTime.getSecs() + replSettings.slavedelay ) ) {
assert( justOne );
oplogReader.putBack( op );
_sleepAdviceTime = nextOpTime.getSecs() + replSettings.slavedelay + 1;
dblock lk;
if ( n > 0 ) {
syncedTo = last;
save();
}
log() << "repl: applied " << n << " operations" << endl;
log() << "repl: syncedTo: " << syncedTo.toStringLong() << endl;
log() << "waiting until: " << _sleepAdviceTime << " to continue" << endl;
return okResultCode;
}