I'm trying to run a query to replace a few pattern in my collection:
db.collection.updateMany({
lastImageUrl: {
"$regex": "kidplus-bucket-eu"
}
},
[
{
$set: {
videos: {
high: {
videoUrl: {
$replaceOne: {
input: "$lastImageUrl",
find: "/kidplus-bucket-eu",
replacement: "/kidplus-bucket-demo"
}
}
}
}
}
},
{
$set: {
videos: {
high: {
videoUrl: {
$replaceOne: {
input: "$lastImageUrl",
find: "/kidplus-bucket-eu",
replacement: "/kidplus-bucket-demo"
}
}
}
}
}
},
{
$set: {
lastImageUrl: {
$replaceOne: {
input: "$lastImageUrl",
find: "/kidplus-bucket-eu",
replacement: "/kidplus-bucket-demo"
}
}
}
}
])
But i'm getting this error: MongoError: Unrecognized expression '$replaceOne' I have tried using $replaceAll instead but im getting the same error...
Does anyone know what's wrong here? TY!
After searching the internet I have found out that my db is outdated (v4.2.22) and the replaceOne command was introduced in v4.4.
Is there any alternative for it so that my query would work?