I Have a mongoose model for a coin that has
coinName: {
type: String,
required: true,
},
category: {
type: String,
},
I want to get all the coinNames associated with a category
Right now I have this code
const coins = await Coin.find().distinct('category',(error, categories) => {
})
which gives me all the categories of the coins.
How can I get all the coins within a category?
Thank you
try find expretion give filter
const coins = await Coin.find({
category: 'catagory name'
})
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.