MongoDB创建集合失败
我正在尝试MongoDB创建集合失败,mongodb,Mongodb,我正在尝试 1.创建数据库 use testdb switched to db testdb 二,。创建集合 testdb.createCollection(testcollection) 我遇到以下错误: 2015-05-12T11:21:19.619-0700 E QUERY ReferenceError: testdb is not defined at (shell):1:1 正确的方法是使用该方法,代码会失败,因为testdb在调用testdb.createColl
1.创建数据库
use testdb switched to db testdb
二,。创建集合
testdb.createCollection(testcollection)
我遇到以下错误:
2015-05-12T11:21:19.619-0700 E QUERY ReferenceError: testdb is not defined
at (shell):1:1
正确的方法是使用该方法,代码会失败,因为
testdb
在调用testdb.createCollection(testcollection)
中不是mongodb对象。请尝试以下操作:
> use testdb
switched to db testdb
> db.createCollection("testcollection")
{ "ok" : 1 }
> db.getCollectionNames()
[ "system.indexes", "testcollection" ]
>
应该是
db.createCollection(“testcollection”)