Ticket bulkWrite: MongoError: the update operation document must contain atomic operators

I must be missing something minor, but the updateMany call
const { modifiedCount } = await mflix.collection('movies').updateMany(moviesToMigrate, { ordered: false });

is failing with the following error: MongoError: the update operation document must contain atomic operators.

Added a console.log to pull the first item off the array, and it seems like it should be valid:

Full output of the script is as follows:
node src/migrations/movie-last-updated-migration.js
(node:12412) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to MongoClient.connect.
Found 23539 documents to update
Error during migration, MongoError: the update operation document must contain atomic operators.

Doesn’t seem to be an issue with the filtering or projection as it’s grabbing the records and generating the array fine (23539 documents to update). Not sure what I’m missing on the updateMany… Full code is as follows:
const predicate = {
‘lastupdated’: {
‘$exists’: true,
‘$type’: ‘string’
const projection = { lastupdated: 1 };
const cursor = await mflix
.find(predicate, projection)
const moviesToMigrate = cursor.map(({ _id, lastupdated }) => ({
updateOne: {
filter: { _id: ObjectId(_id) },
update: {
set: { lastupdated: new Date(Date.parse(lastupdated)) }, }, }, })) console.log( "\x1b[32m", `Found {moviesToMigrate.length} documents to update`,
// TODO: Complete the BulkWrite statement below
const { modifiedCount } = await mflix.collection(‘movies’).updateMany(moviesToMigrate, { ordered: false });

In case it’s many node version related…
node -v

Any guidance is greatly appreciated.

Figured I’d give things a shot with updateOne and pulling the fitler and update from the first element of the array…

Added the following before the updateMany to see what would happen:

const { modifiedCount: test } = await mflix.collection(‘movies’).updateOne(moviesToMigrate[0].updateOne.filter, moviesToMigrate[0].updateOne.update);

It is indeed updating the document in the collection. Subsequent runs are showing the number of documents to update decreasing. So, I’m not sure what’s going on with updateMany…

Don’t I feel like a bonehead… bulkWrite, not updateMany :rofl: