【问题标题】:query argument of mongoexportmongoexport 的查询参数
【发布时间】:2014-02-03 14:42:12
【问题描述】:

mongoexport 实用程序的 query 参数的正确格式是什么?

在命令行中运行以下命令时:

   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

阅读Mongo Export query argJSONDocument docs 并没有帮助我理解查询参数的预期格式。

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

【问题讨论】:

    标签: json mongodb mongoexport


    【解决方案1】:

    如果:

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

    您必须按如下方式构建查询:

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

    【讨论】:

      【解决方案2】:

      问题在于您的new Date() 命令。这没有有效的 json。试试这个:

      mongoexport -h localhost:27000 -d DeploymentJan01 -c sensorsData -q '{sendToServerTime: { $gt: "2014-01-28T12:00:00Z"}}' -o output.js
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-02-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多