I am facing an issue while trying to retrieve an object from an array within a Model. Despite verifying my query params and confirming that they are correct, I am unable to get it to function as expected. Any assistance on this matter would be highly appreciated!
Schema:
const mongoose = require('mongoose');
const { Schema } = mongoose;
const collectionSchema = new Schema({
type: String,
name: String,
id: String,
gamesCollected: [
{
id: Number,
name: String,
summary: String,
first_release_date: Number,
screenshots: [
{
url: String,
couldinary_id: String,
width: Number,
height: Number
}
],
cover: {
url: String,
couldinary_id: String,
width: Number,
height: Number
},
platfroms: [
Number
]
}
]
});
mongoose.model('collection', collectionSchema);
Route:
router.delete('/delete_game', (req, res) => {
Collection.findOneAndUpdate({_id: req.query.collectionID}, {$pull:
{gamesCollected: {_id: req.query.id}}});
res.end();
});