Writing this query in ROBO 3T the code is running properly But in nodejs the code is not working. //schema model
const mongoose = require('mongoose');
const imageSchema = mongoose.Schema({
image: [{
type: String
}],
date: {
type: Date,
default: Date.now
}
});
const Image = module.exports = mongoose.model('Image', imageSchema);
//this code run properly
db.images.updateOne(
{_id:ObjectId("5eeb3273977faa1f7419620e")},
{ $pull: { image: "image-1592472179452.png"} }
)
//this code not run
Image.updateOne({ _id: "5eeb3273977faa1f7419620e" },{$pull:{image: "image-1592472179482.png"}});
Change your export:
module.exports = mongoose.model('Image', imageSchema);
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.