N
N
Nikolai Antonov2016-10-09 19:33:59
MongoDB
Nikolai Antonov, 2016-10-09 19:33:59

Why doesn't db.createCollection('new-test') create a collection from node.js script?

I try to work with mongoDB without mongoose, I connect and try to create a collection, there are no errors, but when I enter the database from the console, there is no collection. What is the problem?
My code:

MongoClient.connect(DB_URL, function(err, db) {
                assert.equal(null, err);

                db.createCollection('new-test');

                db.close();
            });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
catHD, 2016-10-10
@my-nickname

What does "I'm trying to work with mongoDB without mongoose" mean, use native, so there is no createCollection.
mongodb.github.io/node-mongodb-native/2.2/api
https://mongodb.github.io/node-mongodb-native/api-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question