Top Mongoose queries you must know.
- Get link
- X
- Other Apps
Top Mongoose queries you must know.
-To show database - show dbs.
-To create database - use databasename
-To show current db - db
-To show collections - show collections
-To show document in the collection - db.msndata.find()
-To show document in the collection - db.msndata.find().pretty()
-To exit - press ctrl c or type quit()
-To insert single document - db.collectionname.insertOne(key:"value", active:true)
-To insert many document - db.collectionname.insertMany([{key:"value", active:true}, {key:"value", active:true}])
-To show data with where condition - db.msndata.find({name:"NodeJs"}).pretty()
-To show data with where condition and show only that field - db.msndata.find({name:"NodeJs"}, {name:1}).pretty()
-To not show name field - db.msndata.find({name:"NodeJs"}, {name:0}).pretty()
-To not show id field but name only - db.msndata.find({name:"NodeJs"}, {_id:0, name:1}).pretty()
-To show only one result - db.msndata.find({active:true}).pretty().limit(1) or db.msndata.findOne({active:true})
-To skip 1 document and show next - db.msndata.find({active:true}).pretty().limit(1).skip(1).
Thank you.
- Get link
- X
- Other Apps
Comments
Post a Comment