My mongoDB commands

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",
(...)
}
db.user.update({"_id":"1"}, {$set:{"foo.@type":"bar"}})

Comments

Popular posts from this blog

Hibernate - HibernateException: createQuery is not valid without active transaction