【问题标题】:Mongoimport of json file works but db.foo.find() doesn't displayjson 文件的 Mongoimport 有效,但 db.foo.find() 不显示
【发布时间】:2012-09-11 14:44:52
【问题描述】:

我在这里缺少什么?导入了 300 个对象,但我用 find() 看不到它们

导入 JSON 文件:

mongoimport --host localhost -db foo -collection bar --file onebigline.json
connected to: localhost
Tue Sep 11 10:36:58 imported 300 objects
MongoDB shell version: 2.2.0

启动Mongo

connecting to: test
> show dbs
foo 0.203125GB
local   (empty)
> use foo
switched to db foo

显示从 db foo 导入的 JSON 数据

> db.foo.find()
>

【问题讨论】:

    标签: json mongodb find


    【解决方案1】:

    mongoimport 命令中的集合名称是bar,而不是foo,所以试试:

    > db.bar.find()
    

    【讨论】:

    • 谢谢!我试过 db.foo.bar.find() 但没有 db.bar.find()。那行得通!谢谢。
    猜你喜欢
    • 2013-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-09
    • 1970-01-01
    • 2018-03-19
    相关资源
    最近更新 更多