Skip to content

MongoDB Commands

Nimrod Becker edited this page Feb 8, 2016 · 1 revision

see all dbs
show dbs

use specific db
use <dbname>

show tables/collections in db
show collections

select entire table/collection
db.<collection name>.find()

select specific columns/members for entire collection here
db.nodes.find({},{<col1>:1,<col2>:1}).pretty() example: db.nodes.find({},{peer_id:1,hostname:1,name:1,ip:1})

insert here

update here

delete here

CRUD tutorials here

delete old nodes

db.nodes.remove({"heartbeat": {"$lte": new Date("2015-05-28T00:00:00.000Z")}})

add resources to system

db.systems.update({"_id" : ObjectId("XXXXX")},{ $set: {"resources": { "agent_installer": "noobaa-setup.exe", "s3rest_installer" : "noobaa-s3rest.exe" }}})

update file name

db.objectmds.update({"key": /.2823351./},{$set: {"key":"2823351"}})

Clone this wiki locally