Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1> use CgProductDB
- switched to db CgProductDB
- *********************************************************************************************************************************
- 2> db.ProductCollection.insert([{ product_id:1,item:"Laptop",product_Category :"E
- lectronics",product_price:30000.0,product_quantity: 2,orderInfo:{order_id:"O001"
- ,orderdate: ISODate("2014-01-01"),address:{street:"66,Airoli",city:"Mumbai",stat
- e:"MS",zipcode:700987,coords: [ -73.856077, 40.848447 ]},email:"capgemini@capgem
- ini.com",mobiles:[8888108810]}}])
- BulkWriteResult({
- "writeErrors" : [ ],
- "writeConcernErrors" : [ ],
- "nInserted" : 1,
- "nUpserted" : 0,
- "nMatched" : 0,
- "nModified" : 0,
- "nRemoved" : 0,
- "upserted" : [ ]
- })
- db.ProductCollection.insert([{ _id:1,item:"Laptop",prodCat :"Electronics",price:30000.0,quantity: 2,orderInfo:{_id:"O001",orderdate: ISODate("2014-01-01"),address:{street:"66,Airoli",city:"Mumbai",state:"MS",zipcode:700987,coords: [ -73.856077, 40.848447 ]},email:"capgemini@capgemini.com",mobiles:[8888108810]}}])db.ProductCollection.insert([{ _id:1,item:"Laptop",prodCat :"Electronics",price:30000.0,quantity: 2,orderInfo:{_id:"O001",orderdate: ISODate("2014-01-01"),address:{street:"66,Airoli",city:"Mumbai",state:"MS",zipcode:700987,coords: [ -73.856077, 40.848447 ]},email:"capgemini@capgemini.com",mobiles:[8888108810]}}])db.ProductCollection.insert([{ _id:1,item:"Laptop",prodCat :"Electronics",price:30000.0,quantity: 2,orderInfo:{_id:"O001",orderdate: ISODate("2014-01-01"),address:{street:"66,Airoli",city:"Mumbai",state:"MS",zipcode:700987,coords: [ -73.856077, 40.848447 ]},email:"capgemini@capgemini.com",mobiles:[8888108810]}}])
- *******************************************************************************************************************************************************************************
- 3> db.ProductCollection.insert([{ product_id:8,item:"DiamondNecklace",product_Cat
- egory :"Jewellery",product_price:500000.0,product_quantity: 2,orderInfo:{order_i
- d:"O008",orderdate: ISODate("2014-08-08"),address:{street:"66,Airoli",city:"mumb
- ai",state:"Maharastra",zipcode:780063,coords: [ -73.856077, 40.848447 ]},email:"
- capgemini@capgemini.com",mobiles:[8888108818]}}])
- BulkWriteResult({
- "writeErrors" : [ ],
- "writeConcernErrors" : [ ],
- "nInserted" : 1,
- "nUpserted" : 0,
- "nMatched" : 0,
- "nModified" : 0,
- "nRemoved" : 0,
- "upserted" : [ ]
- })
- 4> db.ProductCollection.find().pretty();
- {
- "_id" : ObjectId("5be6ae352f76d6870aba379e"),
- "product_id" : 1,
- "item" : "Laptop",
- "product_Category" : "Electronics",
- "product_price" : 30000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O001",
- "orderdate" : ISODate("2014-01-01T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Mumbai",
- "state" : "MS",
- "zipcode" : 700987,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108810
- ]
- }
- }
- {
- "_id" : ObjectId("5be6af952f76d6870aba379f"),
- "product_id" : 2,
- "item" : "necklace",
- "product_Category" : "Jewellery",
- "product_price" : 10000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O002",
- "orderdate" : ISODate("2014-02-02T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Hyderabad",
- "state" : "TG",
- "zipcode" : 500063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108811
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b00f2f76d6870aba37a0"),
- "product_id" : 3,
- "item" : "pen",
- "product_Category" : "Stationary",
- "product_price" : 10,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O003",
- "orderdate" : ISODate("2014-02-02T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Bangalore",
- "state" : "karnataka",
- "zipcode" : 600063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108812
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b08c2f76d6870aba37a1"),
- "product_id" : 4,
- "item" : "Jacket",
- "product_Category" : "Clothing",
- "product_price" : 10,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O004",
- "orderdate" : ISODate("2014-04-04T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Chennai",
- "state" : "TN",
- "zipcode" : 700063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108812
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b1082f76d6870aba37a2"),
- "product_id" : 5,
- "item" : "Cap",
- "product_Category" : "Clothing",
- "product_price" : 250,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O005",
- "orderdate" : ISODate("2014-05-05T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Pune",
- "state" : "Maharastra",
- "zipcode" : 900063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108815
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b16d2f76d6870aba37a3"),
- "product_id" : 6,
- "item" : "TV",
- "product_Category" : "Electronics",
- "product_price" : 25000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O006",
- "orderdate" : ISODate("2014-06-06T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Delhi",
- "state" : "NCR",
- "zipcode" : 200063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108816
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b1cb2f76d6870aba37a4"),
- "product_id" : 7,
- "item" : "pencil",
- "product_Category" : "Stationary",
- "product_price" : 5,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O007",
- "orderdate" : ISODate("2014-07-07T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Kolkatta",
- "state" : "WB",
- "zipcode" : 300063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108817
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b2d12f76d6870aba37a5"),
- "product_id" : 8,
- "item" : "DiamondNecklace",
- "product_Category" : "Jewellery",
- "product_price" : 500000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O008",
- "orderdate" : ISODate("2014-08-08T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "mumbai",
- "state" : "Maharastra",
- "zipcode" : 780063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108818
- ]
- }
- }
- >
- ****************************************************************************************************************************************************************************************************************************
- 5> db.ProductCollection.find({"product_id":5}).pretty()
- {
- "_id" : ObjectId("5be6b1082f76d6870aba37a2"),
- "product_id" : 5,
- "item" : "Cap",
- "product_Category" : "Clothing",
- "product_price" : 250,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O005",
- "orderdate" : ISODate("2014-05-05T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Pune",
- "state" : "Maharastra",
- "zipcode" : 900063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108815
- ]
- }
- }
- ***************************************************************************************************************************************************************************************************************************
- 6> db.ProductCollection.find({},{product_id:1}).pretty()
- {
- "_id" : ObjectId("5be6ae352f76d6870aba379e"),
- "item" : "Laptop",
- "product_Category" : "Electronics",
- "product_price" : 30000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O001",
- "orderdate" : ISODate("2014-01-01T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Mumbai",
- "state" : "MS",
- "zipcode" : 700987,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108810
- ]
- }
- }
- {
- "_id" : ObjectId("5be6af952f76d6870aba379f"),
- "item" : "necklace",
- "product_Category" : "Jewellery",
- "product_price" : 10000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O002",
- "orderdate" : ISODate("2014-02-02T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Hyderabad",
- "state" : "TG",
- "zipcode" : 500063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108811
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b00f2f76d6870aba37a0"),
- "item" : "pen",
- "product_Category" : "Stationary",
- "product_price" : 10,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O003",
- "orderdate" : ISODate("2014-02-02T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Bangalore",
- "state" : "karnataka",
- "zipcode" : 600063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108812
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b08c2f76d6870aba37a1"),
- "item" : "Jacket",
- "product_Category" : "Clothing",
- "product_price" : 10,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O004",
- "orderdate" : ISODate("2014-04-04T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Chennai",
- "state" : "TN",
- "zipcode" : 700063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108812
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b1082f76d6870aba37a2"),
- "item" : "Cap",
- "product_Category" : "Clothing",
- "product_price" : 250,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O005",
- "orderdate" : ISODate("2014-05-05T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Pune",
- "state" : "Maharastra",
- "zipcode" : 900063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108815
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b16d2f76d6870aba37a3"),
- "item" : "TV",
- "product_Category" : "Electronics",
- "product_price" : 25000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O006",
- "orderdate" : ISODate("2014-06-06T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Delhi",
- "state" : "NCR",
- "zipcode" : 200063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108816
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b1cb2f76d6870aba37a4"),
- "item" : "pencil",
- "product_Category" : "Stationary",
- "product_price" : 5,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O007",
- "orderdate" : ISODate("2014-07-07T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Kolkatta",
- "state" : "WB",
- "zipcode" : 300063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108817
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b2d12f76d6870aba37a5"),
- "item" : "DiamondNecklace",
- "product_Category" : "Jewellery",
- "product_price" : 500000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O008",
- "orderdate" : ISODate("2014-08-08T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "mumbai",
- "state" : "Maharastra",
- "zipcode" : 780063,
- "coords" : [
- -73.856077,
- 40.848447
- ]k
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108818
- ]
- }
- }
- >
- **************************************************************************************************************************************************************************************************************************
- 7> db.ProductCollection.find({},{"orderInfo.email":0,"orderInfo.address.coords":0
- }).pretty()
- {
- "_id" : ObjectId("5be6ae352f76d6870aba379e"),
- "product_id" : 1,
- "item" : "Laptop",
- "product_Category" : "Electronics",
- "product_price" : 30000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O001",
- "orderdate" : ISODate("2014-01-01T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Mumbai",
- "state" : "MS",
- "zipcode" : 700987
- },
- "mobiles" : [
- 8888108810
- ]
- }
- }
- {
- "_id" : ObjectId("5be6af952f76d6870aba379f"),
- "product_id" : 2,
- "item" : "necklace",
- "product_Category" : "Jewellery",
- "product_price" : 10000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O002",
- "orderdate" : ISODate("2014-02-02T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Hyderabad",
- "state" : "TG",
- "zipcode" : 500063
- },
- "mobiles" : [
- 8888108811
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b00f2f76d6870aba37a0"),
- "product_id" : 3,
- "item" : "pen",
- "product_Category" : "Stationary",
- "product_price" : 10,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O003",
- "orderdate" : ISODate("2014-02-02T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Bangalore",
- "state" : "karnataka",
- "zipcode" : 600063
- },
- "mobiles" : [
- 8888108812
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b08c2f76d6870aba37a1"),
- "product_id" : 4,
- "item" : "Jacket",
- "product_Category" : "Clothing",
- "product_price" : 10,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O004",
- "orderdate" : ISODate("2014-04-04T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Chennai",
- "state" : "TN",
- "zipcode" : 700063
- },
- "mobiles" : [
- 8888108812
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b1082f76d6870aba37a2"),
- "product_id" : 5,
- "item" : "Cap",
- "product_Category" : "Clothing",
- "product_price" : 250,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O005",
- "orderdate" : ISODate("2014-05-05T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Pune",
- "state" : "Maharastra",
- "zipcode" : 900063
- },
- "mobiles" : [
- 8888108815
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b16d2f76d6870aba37a3"),
- "product_id" : 6,
- "item" : "TV",
- "product_Category" : "Electronics",
- "product_price" : 25000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O006",
- "orderdate" : ISODate("2014-06-06T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Delhi",
- "state" : "NCR",
- "zipcode" : 200063
- },
- "mobiles" : [
- 8888108816
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b1cb2f76d6870aba37a4"),
- "product_id" : 7,
- "item" : "pencil",
- "product_Category" : "Stationary",
- "product_price" : 5,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O007",
- "orderdate" : ISODate("2014-07-07T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Kolkatta",
- "state" : "WB",
- "zipcode" : 300063
- },
- "mobiles" : [
- 8888108817
- ]
- }
- }
- {
- "_id" : ObjectId("5be6b2d12f76d6870aba37a5"),
- "product_id" : 8,
- "item" : "DiamondNecklace",
- "product_Category" : "Jewellery",
- "product_price" : 500000,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O008",
- "orderdate" : ISODate("2014-08-08T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "mumbai",
- "state" : "Maharastra",
- "zipcode" : 780063
- },
- "mobiles" : [
- 8888108818
- ]
- }
- }
- >
- *************************************************************************************************************************************************************************************************************************
- 8> db.ProductCollection.update({"product_id":3},{$set : {"orderInfo.order_status"
- :"pending"}})
- WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
- > db.ProductCollection.find({product_id:3}).pretty()
- {
- "_id" : ObjectId("5be6b00f2f76d6870aba37a0"),
- "product_id" : 3,
- "item" : "pen",
- "product_Category" : "Stationary",
- "product_price" : 10,
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O003",
- "orderdate" : ISODate("2014-02-02T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Bangalore",
- "state" : "karnataka",
- "zipcode" : 600063,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108812
- ],
- "order_status" : "pending"
- },
- "order_status" : "pending"
- }
- >
- *******************************************************************************************************************************************************************************************************************************
- 9> db.ProductCollection.update({"product_id":3},{$set : {"order_status":"pending"
- }})
- WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
- **********************************************************************************************************************************************************************************************************************************
- > db.ProductCollection.update({"product_price":30000},{$set : {"product_price":"
- 50000"}})
- WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
- > db.ProductCollection.find({product_id:1}).pretty()
- {
- "_id" : ObjectId("5be6ae352f76d6870aba379e"),
- "product_id" : 1,
- "item" : "Laptop",
- "product_Category" : "Electronics",
- "product_price" : "50000",
- "product_quantity" : 2,
- "orderInfo" : {
- "order_id" : "O001",
- "orderdate" : ISODate("2014-01-01T00:00:00Z"),
- "address" : {
- "street" : "66,Airoli",
- "city" : "Mumbai",
- "state" : "MS",
- "zipcode" : 700987,
- "coords" : [
- -73.856077,
- 40.848447
- ]
- },
- "email" : "capgemini@capgemini.com",
- "mobiles" : [
- 8888108810
- ]
- }
- }
- >
- *******************************************************************************************************************************************************************************************************************************
Add Comment
Please, Sign In to add comment