@Dmehaffy, thanks for your feedback. I followed the Strapi controller docs and after playing around with many different iterations of the code below, I’m still stuck.
`const { parseMultipartData, sanitizeEntity } = require(“strapi-utils”);
module.exports = {
async update(ctx) {
const { id } = ctx.params;
const { user } = ctx.state;
let entity;
if (ctx.is("multipart")) {
const { data, files } = parseMultipartData(ctx);
entity = await strapi.services.product.update({ id }, data, {
files,
});
} else {
// return id; = 5fa47483e87eddaad31766c6 from const { id } = ctx.params;
entity = await strapi.services.product
.update({ id }, ctx.request.body, {
$pull: {
userCarts: {
_id: "5f832758ef13ed4f801c8937",
},
},
})
}
return sanitizeEntity(entity, { model: strapi.models.product });
}
}`
My product is returned but the userCarts item is not deleted.
I also tested code that was suggested on Strapi’s Slack channel by replacing:
entity = await strapi.services.product.update(
with
entity = await strapi.query("product").model.updateOne(
No joy on that code change, either.
Mongoose $pull seems to have a history of issues related to not working. From what I’ve read, it essentially depends on “_id”, though some have had success using other fields as target values. “_id” is my target value for userCarts.
Does Strapi have its own implementation for $pull?
Thoughts?
Thanks… Jim