query argument of mongoexport

断了今生、忘了曾经 提交于 2019-12-11 06:16:37

问题


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.


回答1:


If:

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

You will have to construct your query as follows:

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



回答2:


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


来源:https://stackoverflow.com/questions/21530209/query-argument-of-mongoexport

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!