質問

What is the right format of query argument of mongoexport utility?

While running the following command in the command line:

   mongoexport -h localhost:27000 -d dbName -c collName -q "{'time': { $gt: new Date('2014-01-28T12:00:00Z')}}" -o output.js

I'm getting the following error:

connected to: localhost:27000 assertion: 16619 code FailedToParse: FailedToParse: Expecting '}' or ',': offset:37

Reading Mongo Export query arg and JSONDocument docs haven't helped me to understand the expected format of query argument.

Running the same query in mongo shell succeeds.

役に立ちましたか?

解決

If:

>new Date ("2014-01-28T12:00:00Z").getTime()
1390910400000

You will have to construct your query as follows:

-q "{sendToServerTime: {\$gt: {\$date : 1390910400000}}}"

他のヒント

The problem is your new Date() command. This no valid json. Try this:

mongoexport -h localhost:27000 -d DeploymentJan01 -c sensorsData -q '{sendToServerTime: { $gt: "2014-01-28T12:00:00Z"}}' -o output.js
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top