Mongoexport -q ISODate查询 [英] Mongoexport -q ISODate query

查看:386
本文介绍了Mongoexport -q ISODate查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行此命令:

I'm trying to run this:

mongoexport.exe -h *MYHOST* -p *MYPORT* -q "{'time':{'$gte': ISODate('2014-12-21 12:57:00.506Z'),'$lt': ISODate('2014-12-21 12:59:00.506Z')}}"

或者这(没有-'的gte& lt):

Or this(the gte & lt without - ' ):

mongoexport.exe -h *MYHOST* -p *MYPORT* -q {'time':{$gte: ISODate('2014-12-21 12:57:00.506Z'),$lt: ISODate('2014-12-21 12:59:00.506Z')}}

该查询在Robomongo上运行良好,但是使用mongoexport时会抛出:位置参数过多"

The query works fine on Robomongo, But with mongoexport it throws: "too many positional arguments"

我知道我可以改为运行以下命令,但是我不想每次需要执行查询时都使用日期转换器.

I know I can run the following instead, But I don't want to use the date converter everytime I need to execute a query.

mongoexport.exe -h *MYHOST* -p *MYPORT* -q "{'time':{$gte: new Date(14191
66620506),$lt: new Date(1419166740506)}}"

推荐答案

mongoexport查询需要使用严格模式的MongoDB扩展JSON.您可以在扩展JSON 上的MongoDB手册文章中了解有关扩展JSON风格的更多信息.在您的特定情况下,在mongoexport命令中编写第一个查询的正确方法是

mongoexport queries require the use of strict-mode MongoDB extended JSON. You can read more about that flavor of extended JSON in the MongoDB Manual article on extended JSON. In your specific case, the proper way to write the first query in the mongoexport command is

mongoexport.exe -h *MYHOST* -p *MYPORT* -q "{ 'time' : { '$gte' : { '$date' : '2014-12-21 12:57:00.506Z' },'$lt' : { '$date' : '2014-12-21 12:59:00.506Z' } } }"

这篇关于Mongoexport -q ISODate查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆