Skip to content

Instantly share code, notes, and snippets.

@moziauddin
Last active December 27, 2018 05:22
Show Gist options
  • Save moziauddin/275b53c6087b31d43ff0f119ea89ba05 to your computer and use it in GitHub Desktop.
Save moziauddin/275b53c6087b31d43ff0f119ea89ba05 to your computer and use it in GitHub Desktop.
MongoDB

db.getProfilingLevel()

0

db.setProfilingLevel(2)

{ "was" : 0, "slowms" : 100, "sampleRate" : 1, "ok" : 1 }

db.getProfilingLevel()

2

show dbs

admin   0.000GB
config  0.000GB
local   0.000GB

use fullstack

switched to db fullstack

show collections

db.students.insert({"name": "Mo", "marks": 99})

WriteResult({ "nInserted" : 1 })

db.students.find()

{ "_id" : ObjectId("5c23a9ea11bebd0c676e00dd"), "name" : "Mo", "marks" : 99 }

db.students.insert({"Object": "Table", "price": 120, "location": "Sydney"})

WriteResult({ "nInserted" : 1 })

db.students.find()

{ "_id" : ObjectId("5c23a9ea11bebd0c676e00dd"), "name" : "Mo", "marks" : 99 }
{ "_id" : ObjectId("5c23aa5511bebd0c676e00de"), "Object" : "Table", "price" : 12
0, "location" : "Sydney" }

db.students.remove({"price": 120})

WriteResult({ "nRemoved" : 1 })

db.students.find()

{ "_id" : ObjectId("5c23a9ea11bebd0c676e00dd"), "name" : "Mo", "marks" : 99 }

db.students.remove({})

WriteResult({ "nRemoved" : 1 })

show collections

students

system.indexes

2018-12-27T03:23:16.299+1100 E QUERY    [js] ReferenceError: system is not defin
ed :
@(shell):1:1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment