0

I'm trying to run a mongoexport with the following query:

var d = new Date();
d.setMonth(d.getMonth() - 3);
db.GameHistory.find( { timeCreated: { $lte: d} } )

I want to export all documents with creation Date older then 3 month. I tried this:

mongoexport --db game_server --collection GameHistory -q ' var d = new Date();d.setMonth(d.getMonth() - 3);db.GameHistory.find( { timeCreated: { $lte: d} } )' --out /home/dev/file.json

and got this exception:

assertion: 16619 code FailedToParse: FailedToParse: Expecting '{': offset:0 of:db.GameHistory.find( { timeCreated: { $lte: new Date()} } )

Ideas?

lior
  • 1,127
  • 3
  • 24
  • 43
  • May be you'll get some idea here [link](http://stackoverflow.com/questions/21530209/query-argument-of-mongoexport), a little bit of tweaking should get you to the solution – Robert Christopher Aug 10 '14 at 14:45
  • 2
    -q can only accept a query predicate - so only a json document representing the query, it cannot evaluate arbitrary JS statements. – Asya Kamsky Aug 10 '14 at 22:13
  • OK I understand I cant use js in the command line so how can I do a query with a changing date parameter? – lior Aug 12 '14 at 06:42

0 Answers0