Updated MongoDB 5 rawCollection deprecated update to updateMany (or updateOne).

Thanks to xet7 !
This commit is contained in:
Lauri Ojansivu 2022-04-22 16:32:28 +03:00
parent 3fb709ed70
commit a196a5ed63

View file

@ -717,7 +717,7 @@ Migrations.add('add-missing-created-and-modified', () => {
modifiedAtTables.map(db => modifiedAtTables.map(db =>
db db
.rawCollection() .rawCollection()
.update( .updateMany(
{ modifiedAt: { $exists: false } }, { modifiedAt: { $exists: false } },
{ $set: { modifiedAt: new Date() } }, { $set: { modifiedAt: new Date() } },
{ multi: true }, { multi: true },
@ -725,7 +725,7 @@ Migrations.add('add-missing-created-and-modified', () => {
.then(() => .then(() =>
db db
.rawCollection() .rawCollection()
.update( .updateMany(
{ createdAt: { $exists: false } }, { createdAt: { $exists: false } },
{ $set: { createdAt: new Date() } }, { $set: { createdAt: new Date() } },
{ multi: true }, { multi: true },
@ -772,7 +772,7 @@ Migrations.add('fix-incorrect-dates', () => {
.rawCollection() .rawCollection()
.find({ $or: [{ createdAt: { $type: 1 } }, { updatedAt: { $type: 1 } }] }) .find({ $or: [{ createdAt: { $type: 1 } }, { updatedAt: { $type: 1 } }] })
.forEach(({ _id, createdAt, updatedAt }) => { .forEach(({ _id, createdAt, updatedAt }) => {
t.rawCollection().update( t.rawCollection().updateMany(
{ _id }, { _id },
{ {
$set: { $set: {