Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ----------------------------- general -----------------------
- db // show current database
- show dbs // dhow all databases
- use DB_NAME // create or switch to database
- show collections // show all collections inside a database
- db.runCommand({dropDatabase:1}) // drop current database
- // ----------------------------- Find -----------------------
- db.test.findOne() // display one randmly
- db.test.find() // diplay all
- db.test.find({nom:"smith"},{nom:true,age:true}) // first object is like WHERE 2nd is WHAT TO DISPLAY
- db.test.find({"age":27}) // select * from test where age=27
- db.test.find({},{"nom":1,"age":1}) // select nom,age from test
- db.test.find({},{"nom":0}) // select age,profession from test
- db.test.find({"age":{"$gte":18,"$lte":30}}) // select * from test where age between 18 and 30
- db.test.find({"num":{"$in":[151,254,587]}}) // select * from test where num in (151,254,587)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement