MongoDB creates assembly failures

I am trying

1. Create a database

use testdb switched to db testdb

      

2. Create a collection

testdb.createCollection(testcollection)

      

I am getting the following error:

2015-05-12T11:21:19.619-0700 E QUERY    ReferenceError: testdb is not defined
    at (shell):1:1

      

+3


source to share


1 answer


The correct way is to use a method , your code doesn't work because there is no mongodb object in your call . Try the following: db.createCollection()

testdb

testdb.createCollection(testcollection)



> use testdb
switched to db testdb
> db.createCollection("testcollection")
{ "ok" : 1 }
> db.getCollectionNames()
[ "system.indexes", "testcollection" ]
>

      

+4


source







All Articles