-
Notifications
You must be signed in to change notification settings - Fork 0
CRUD operations
Nikolas Bompetsis edited this page May 30, 2020
·
2 revisions
> mongodb master ✗ mongo -u admin -p admin --authenticationDatabase admin
> use project
- Select all documents
> db.stackoverflow.find({})
- Select documents from Country Greece
> db.stackoverflow.find({Country: "Greece"})
or case sensitive
> db.stackoverflow.find( {Country: /^GREECE$/i})
- Select documents from many Countries Greece
> db.stackoverflow.find( {Country: {$in: ["Greece", "Thailand"]}})
- Select documents from Country Greece and age greater than 30
> db.stackoverflow.find({Country: "Greece", Age: {$gt: 30 }})
- Select documents and return only specific field from query
> db.stackoverflow.find({Country: "Greece", Age: {$gt: 30 }}, {Age:1 , Country:1 , _id:0})