According to tie piece of documentation if I run these upon mongosh:
use myDB
db.myNewCollection1.insertOne( { x: 1 } )
Will automatically create a myDb database and will a collection myNewCollection1.
Therefore if upon my nodejs run:
const {MongoClient, ServerApiVersion} = require('mongodb');
// Connectionstring
const uri = 'mongodb://root:[email protected]:27017/';
// Create a MongoClient with a MongoClientOptions object to set the Stable API version
const client = new MongoClient(uri, {
serverApi: {
version: ServerApiVersion.v1, strict: true, deprecationErrors: true,
}
});
client.connect({poolSize:10});
const database = client.db('myDb');
const collection = database.collection('myNewCollection1')
collection.updateOne({"var":value})
I mean if I run the nodejs code above will automatically create the database myDb and collection myNewCollection1 as would be done via mongosh?