> show dbs; admin 0.000GB config 0.000GB local 0.000GB > db.collection('emp').insertOne("{'empId':'1001','empName':'Scott'}"); 2019-04-16T17:09:05.816+0530 E QUERY [js] TypeError: db.collection is not a function : @(shell):1:1 > db.emp.insertOne({'empId':'1001','empName':'Scott'}); { "acknowledged" : true, "insertedId" : ObjectId("5cb5bf8144cce71ac6ae2444") } > db.emp.insertOne({'empId':'1002','empName':'Jack'}); { "acknowledged" : true, "insertedId" : ObjectId("5cb5bf8e44cce71ac6ae2445") } > show dbs; admin 0.000GB config 0.000GB emp_db 0.000GB local 0.000GB > show collections; emp > use local switched to db local > show collections; startup_log > use emp_db; switched to db emp_db > show collections; emp > db.emp.find(); { "_id" : ObjectId("5cb5bf8144cce71ac6ae2444"), "empId" : "1001", "empName" : "Scott" } { "_id" : ObjectId("5cb5bf8e44cce71ac6ae2445"), "empId" : "1002", "empName" : "Jack" } > db.emp.insertOne({'empName':'Ram','project':'LKM'}); { "acknowledged" : true, "insertedId" : ObjectId("5cb5c12444cce71ac6ae2446") } > db.emp.find(); { "_id" : ObjectId("5cb5bf8144cce71ac6ae2444"), "empId" : "1001", "empName" : "Scott" } { "_id" : ObjectId("5cb5bf8e44cce71ac6ae2445"), "empId" : "1002", "empName" : "Jack" } { "_id" : ObjectId("5cb5c12444cce71ac6ae2446"), "empName" : "Ram", "project" : "LKM" } > db.emp.find( ... {"empName":"Ram"} ... ) { "_id" : ObjectId("5cb5c12444cce71ac6ae2446"), "empName" : "Ram", "project" : "LKM" } > db.emp.update( ... {empName: "Ram}, 2019-04-16T17:23:36.856+0530 E QUERY [js] SyntaxError: unterminated string literal @(shell):2:10 > db.emp.update( {empName:"Ram}, 2019-04-16T17:23:55.392+0530 E QUERY [js] SyntaxError: unterminated string literal @(shell):1:24 > db.emp.update({empName: "Ram}, 2019-04-16T17:24:20.321+0530 E QUERY [js] SyntaxError: unterminated string literal @(shell):1:24 > db.emp.update( ... {name : "Ram"}, ... {$set: {empId:"1003"}} ... ); WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0 }) > db.emp.update( {empName : "Ram"}, {$set: {empId:"1003"}} ); WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) > db.emp.find(); { "_id" : ObjectId("5cb5bf8144cce71ac6ae2444"), "empId" : "1001", "empName" : "Scott" } { "_id" : ObjectId("5cb5bf8e44cce71ac6ae2445"), "empId" : "1002", "empName" : "Jack" } { "_id" : ObjectId("5cb5c12444cce71ac6ae2446"), "empName" : "Ram", "project" : "LKM", "empId" : "1003" } > db.emp.updateMany( ... {$set:{age:25}} ... ); 2019-04-16T17:27:27.882+0530 E QUERY [js] TypeError: can't convert undefined to object : DBCollection.prototype.updateMany@src/mongo/shell/crud_api.js:618:16 @(shell):1:1 > db.emp.updateMany( {$set:{age:'25'}} ); 2019-04-16T17:27:40.154+0530 E QUERY [js] TypeError: can't convert undefined to object : DBCollection.prototype.updateMany@src/mongo/shell/crud_api.js:618:16 @(shell):1:1 > db.emp.updateMany( {$set:{age:"25"}} ); 2019-04-16T17:28:15.195+0530 E QUERY [js] TypeError: can't convert undefined to object : DBCollection.prototype.updateMany@src/mongo/shell/crud_api.js:618:16 @(shell):1:1 > db.emp.updateMany({},{$set:{age:"25"}} ); { "acknowledged" : true, "matchedCount" : 3, "modifiedCount" : 3 } > db.emp.find(); { "_id" : ObjectId("5cb5bf8144cce71ac6ae2444"), "empId" : "1001", "empName" : "Scott", "age" : "25" } { "_id" : ObjectId("5cb5bf8e44cce71ac6ae2445"), "empId" : "1002", "empName" : "Jack", "age" : "25" } { "_id" : ObjectId("5cb5c12444cce71ac6ae2446"), "empName" : "Ram", "project" : "LKM", "empId" : "1003", "age" : "25" } > db.emp.update( {empName : "Ram"}, {$set: {age:"35"}} ); WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) > db.emp.find(); { "_id" : ObjectId("5cb5bf8144cce71ac6ae2444"), "empId" : "1001", "empName" : "Scott", "age" : "25" } { "_id" : ObjectId("5cb5bf8e44cce71ac6ae2445"), "empId" : "1002", "empName" : "Jack", "age" : "25" } { "_id" : ObjectId("5cb5c12444cce71ac6ae2446"), "empName" : "Ram", "project" : "LKM", "empId" : "1003", "age" : "35" } > db.emp.update( ... {age: { $lt: 30 }}, ... {$set:{project:"Fresher"}} ... ); WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0 }) > db.emp.update( {age: { $lt: "30" }}, {$set:{project:"Fresher"}} ); WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) > db.emp.find(); { "_id" : ObjectId("5cb5bf8144cce71ac6ae2444"), "empId" : "1001", "empName" : "Scott", "age" : "25", "project" : "Fresher" } { "_id" : ObjectId("5cb5bf8e44cce71ac6ae2445"), "empId" : "1002", "empName" : "Jack", "age" : "25" } { "_id" : ObjectId("5cb5c12444cce71ac6ae2446"), "empName" : "Ram", "project" : "LKM", "empId" : "1003", "age" : "35" } > db.emp.deleteOne( ... {project:"Fresher"} ... ); { "acknowledged" : true, "deletedCount" : 1 } > db.emp.find(); { "_id" : ObjectId("5cb5bf8e44cce71ac6ae2445"), "empId" : "1002", "empName" : "Jack", "age" : "25" } { "_id" : ObjectId("5cb5c12444cce71ac6ae2446"), "empName" : "Ram", "project" : "LKM", "empId" : "1003", "age" : "35" }