Let data = {
_id : "7302774",
count : 25,
Itmems : [{
image: "abc",
url: "28rudjj.com"
},
{
image: "abcd",
url: "aaa.com"
}
]
}
My mongodb data
I hope, change url
Example const oldUrl = "aaa.com" const newUrl = "bbb.com"
Let data = {
_id : "7302774",
count : 25,
Itmems : [{
image: "abc",
url: "28rudjj.com"
},
{
image: "abcd",
url: "bbb.com"
}
]
}
hope result
await strapi.query('item').model.updateMany([
{ items: { $elemMatch: { url: oldUrl } } },
{
$project: {
items: {
$filter: {
input: '$items',
as: 'item',
cond: {
$eq: ['$$item.url', oldUrl]
}
}
}
}
},
{ $set: { items: { url: newUrl } } }
])
I try this code and updateMany => aggregate also error help me mongodb god user!!
If you have any information you want, I'll give you more.