【问题标题】:Export collection in mongodb using shell command使用 shell 命令在 mongodb 中导出集合
【发布时间】:2012-07-29 08:02:50
【问题描述】:

我想使用 shell 命令在 mongodb 中导出集合: 我尝试以下命令,但未导出带有“:”(号码:电话,号码:传真)的字段。

mongoexport --csv -d schemaName -c collectionName -q "{typeName:'user'}" -f "name, surname, e-mail, number:phone, number:fax" -o export.csv

【问题讨论】:

  • 您能否发布您尝试导出的文档的示例?
  • 这是示例文档。 {'path': '/users/sarahperez', 'name':'Sarah', 'surname':'Perez', 'e-mail':'sarahperez@sarahperez.com','number:phone':'00421236523','number:fax':'004215377853'} {'path': '/users/ericeldon', 'name':'Eric', 'surname':'Eldon', 'e-mail':'ericeldon@ericeldon.com','number:phone':'00421276823','number:fax':'0042165928725'}@珍娜
  • 嗯,我认为问题可能与字段名称中包含冒号这一事实有关。我可以使用点表示法导出嵌入文档的字段,例如 {number: {fax: 123, cell: 345}}。我会继续调查。
  • 您可以将其导出为 JSON,而不是 CSV

标签: json mongodb export export-to-csv


【解决方案1】:

我认为您发现了一个合法的错误。 mongoexport 工具很少使用,而冒号在解析 JSON 时意味着非常具体的东西,因此该工具可能会被混淆。

您可以在此处提交错误:http://jira.mongodb.org/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 2015-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多