MongoDB CLI 101 Fundamentals 

[Angel@localhost ~]$ mongo
> show collections; //equivalent to rdbms tables
> use test; //use test db
> db.test.count();
> db.test.find(); //all documents, a document is like a rdbms row.
> db.test.find({_id:ObjectId("52c351ffc5c629a6ca901ae5")});// where _id equals to...
> db.test.find({_id:ObjectId("52c351ffc5c629a6ca901ae5")},{'_id':0}); // _id field is not displayed
> db.test.update({_id:ObjectId("52c351ffc5c629a6ca901ae5")},{'field-to-update':'new-value'});//updating a field
> db.test.update({_id:ObjectId("52c351ffc5c629a6ca901ae5")},{$set:{'Year':2014}}); //add new field



[ view entry ] ( 1522 views )   |  print article

<<First <Back | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Next> Last>>



2024 By Angel Cool