Hello. Im trying to compare new data to the existing and update all documents in my collection that has diferent values. I using this function but its not working. Can anyone help me. Thank you
Error
Unknown modifier: $or. Expected a valid update modifier or pipeline-style update specified as an array
use('mongodbVSCodePlaygroundDB')
let new_data = [
{ item: 'abc', price: 99, quantity: 999, date: new Date('2014-03-01T08:00:00Z') },
{ item: 'jkl', price: 20, quantity: 1, date: new Date('2014-03-01T09:00:00Z') },
{ item: 'xyz', price: 5, quantity: 10, date: new Date('2014-03-15T09:00:00Z') },
]
// Insert a few documents into the sales collection.
db.getCollection('sales').updateMany( {},
{
$or: [
{ item: { $ne: new_data.item } },
{ price: { $ne: new_data.price } },
{ quantity: { $ne: new_data.quantity } },
{ date: { $ne: new_data.date } },
],
},
{
$set: {
item: new_data.item,
price: new_data.price,
quantity: new_data.quantity,
date: new_data.date,
},
},
)