MongoDB is an alternative to conventional SQL databases. It is one of the most popular NoSQL databases and it is primarly used because of performance, scalability and ease-of-use.
It is especially easy to use with JavaScript!
If the collection doesn’t exist, Mongo will automatically create it with the Insert data. But if you want to create an empty collection, you can do:
db.createCollection( "collectionName", { ...[options] } );
You can insertOne or insertMany data in a collection. Check it out:
db.insertOne({ name: 'Johnny', age: undefined });
db.insertMany([{ name: 'Carlos', age: 11 }, { name: 'Amy', age: 23 }]);
Work similarly to insertOne and insertMany:
db.inventory.deleteOne({ quantity: 100 }); // Delete first document with quantity 100
db.inventory.deleteOne({ _id: "12ajg23" }); // Delete document with _id = 12ajg23
db.inventory.deleteMany({ price: { $gt: 100 } }); // Delete every with price greater than 100
db.inventory.deleteMany({}); // Delete every document in collection