DB: MongoDB Community Server
GUI: Compass
mongo
show dbs
use myfirstdb
db.createCollection("user")
db.createCollection("profile")
show collections
db.profile.drop()
db.dropDatabase()
db.profile.insert({"name":"abc",age:10})
db.profile.find()
db.profile.insert({_id:2,"name":"sdf",age:20})
db.profile.find().pretty()
db.profile.find().count()
db.profile.insertOne({"name":"ert",city:"FL"})
db.profile.insertMany([{"name":"ghj",age:25},{"name":"yui",city:"IL"},{"name":"sdf",age:15}])
db.profile.find({name:"abc"}).pretty()
db.profile.find({age:{$gt:25}}).pretty()
db.profile.find({age:{$gte:25}}).pretty()
db.profile.find({age:{$lt:25}}).pretty()
db.profile.find({age:{$lte:25}}).pretty()
db.profile.find({age:{$eq:25}}).pretty()
db.profile.find({$and:[name:"abc",{age:25}]}).pretty()
db.profile.find({$or:[name:"abc",{age:25}]}).pretty()
db.profile.find({name:{$in:["abc","sdf"]}}).pretty()
db.profile.find({name:{$nin:["abc","sdf"]}}).pretty()
db.profile.find({age:{$not:{$lt:25}}}).pretty()
db.profile.update({name:"abc"},{$set:{city:"TX"}}) //update existing
db.profile.update({name:"abc"},{city:"TX"}) //delete existing insert new
db.profile.find().sort({"age":1}).pretty() //asc:1 Desc: -1
projection
db.profile.find({name:"abc"},{city:1,"_id":0}).pretty() select only city field hide Id field
db.profile.deleteOne({name:"abc"})
db.profile.remove({name:"abc"})
db.profile.remove({name:"abc"},1)
mongodump --db myfirstdb
mongorestore --db myfirstdb