I am trying to
1. Create a database
use testdb switched to db testdb
2. Create collection
testdb.createCollection(testcollection)
I am getting following error:
2015-05-12T11:21:19.619-0700 E QUERY ReferenceError: testdb is not defined
at (shell):1:1
The correct way is by using the db.createCollection() method, your code fails because testdb is not a mongodb object in your call testdb.createCollection(testcollection). Try the following:
> use testdb
switched to db testdb
> db.createCollection("testcollection")
{ "ok" : 1 }
> db.getCollectionNames()
[ "system.indexes", "testcollection" ]
>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With