-
Find all the information about each products.
- Solution :
db.Product.find()
- Solution :
-
Find the product price which are between 400 to 800.
- Solution :
db.Product.find({product_price:{$gt: 400, $lt: 800}})
- Solution :
-
Find the product price which are not between 400 to 600.
- Solution :
db.Product.find({product_price:{$not:{$gt: 400, $lt: 600}}})
- Solution :
-
List the four product which are grater than 500 in price.
- Solution :
db.Product.find({product_price:{$gt: 500}}).limit(4)
- Solution :
-
Find the product name and product material of each products.
- Solution :
db.Product.find({}, {product_name: 1, product_material: 1})
- Solution :
-
Find the product with a row id of 10.
- Solution :
db.Product.find({id:"10"}) (OR) db.Product.find({id:{$eq: '10'}})
- Solution :
-
Find only the product name and product material.
- Solution :
db.products.find({}, { "product_name": 1, "product_material": 1, "_id": 0 }) (OR) db.Product.aggregate({$project:{_id:0, product_name: 1, product_material: 1}})
- Solution :
-
Find all products which contain the value of soft in product material.
- Solution :
db.Product.find({product_material: 'Soft'})
- Solution :
-
Find products which contain product color indigo and product price 492.00.
- Solution :
db.Product.find({$or:[{product_color: 'indigo'}, {product_price: 492}]})
- Solution :
-
Delete the products which product price value are same.
- Solution :
db.Product.aggregate([ { $group: {_id: "$product_price", count: { $sum: 1 }, ids: { $push: "$_id" }} }, { $match: {count: { $gt: 1 }} }, { $unwind: "$ids" } ]).forEach(function(doc){ db.Product.deleteOne({ids: doc.ids.objectId}) })
- Solution :
-
Notifications
You must be signed in to change notification settings - Fork 0
asaltcode/Mongodb-Product
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
This is the answer to mongodb questions
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published