mongoexport的查询参数 [英] query argument of mongoexport

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

问题描述

mongoexport 实用工具的 query 参数的正确格式是什么?

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

我遇到以下错误:

已连接到:localhost:27000断言:16619代码FailedToParse: FailedToParse:期望为}"或,":offset:37

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

阅读 Mongo导出查询arg JSONDocument文档并没有帮助我理解预期的格式查询参数.

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

在mongo shell中运行相同的查询成功.

Running the same query in mongo shell succeeds.

推荐答案

如果:

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

您将必须按照以下方式构造查询:

You will have to construct your query as follows:

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

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

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