Create mongo database:
use <database_name>
Create Collections
db.createCollection(name, options)
db.collection.createIndex({"key":1},{unique:true})
db.collection.deleteMany({}) to delete all items
db.collection.drop() delete collection
Insert if not found otherwise update
use <database_name>
Create Collections
db.createCollection(name, options)
db.collection.createIndex({"key":1},{unique:true})
db.collection.deleteMany({}) to delete all items
db.collection.drop() delete collection
Insert if not found otherwise update
db.people.update( { name: "Andy" }, { name: "Andy", rating: 1, score: 1 }, { upsert: true } )
No comments:
Post a Comment