Clicky

My mongoDB commands

February 19, 2016

Lists all mongo databases

show dbs

Switches to a database

use <database_name>

Lists all database collections

show collections

Deletes all collection content

db.<collection_name>.remove({})

Selects documents having offers with sub-type SingleOffer

db.<collection_name>.find({“offers.@type”:“SingleOffer”}})

Displays all collection content

db.user.find()

Select with AND

db.user.find({“offers.offers.offerID”:“1”, “productID”:“1”})

Single field update 

The follwing command updates the type of the nested under offer

{

“_id” : “1”,
“offer” : {
“@type” : “foo”,

(...)

}