MongoDB Querying

Below are the Basic queries for Mongodb

Select Database

Show dbs- This will show all the database name
use dbname- This will switch to the dbname database
show collections- List all collection details

Query

db.collectionname.find(); List all documents from collectionname collection.

Insert

db.collectionname.save({ name : "vinu"});Note that MongoDB will implicitly create any collection that doesn’t already exist

Update

collectionname = db.collectionname.findOne( { name : "vinu" } );

collectionname.lastname= "Raj";

db.collectionname.save(collectionname);

Delete

db.collectionname.drop() - remove entire collectionname collection
db.collectionname.remove() - remove all objects
db.collectionname.remove({name: "vinu"})


 

No comments:

Post a Comment

Confusion Matrix + Precision/Recall (Super Simple, With Examples)

  Confusion Matrix + Precision/Recall (Super Simple, With Examples) 1) Binary Classification Setup Binary classification means the model p...

Featured Posts