I have a JSON object on MongoDB
I can`t understand how to get Products by ID from the Menu?
You can read that by using the following command.
To read a single data from array:
db.dbname.findOne({'products':
{$elemMatch:{
'_id': id_of_the_product_you_want_to_read
}
}})
You can change the parameters _id to the necessary parameter you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.