Skip to content

Commit

Permalink
Merge branch 'staging' into feature/entity-entity-relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
clari182 committed Oct 29, 2024
2 parents c0f3b3b + 9a015b5 commit 98f2d74
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const config = require('../config');

/** @type {import('umzug').MigrationFn<any>} */
exports.up = async ({ context: { client } }) => {
const reportsCollection = client.db(config.realm.production_db.db_name).collection('reports');

// Change "AIAAIC" to "Anonymous" if it is the only element in the `submitters` array
const result1 = await reportsCollection.updateMany(
{ submitters: ['AIAAIC'] },
{ $set: { submitters: ['Anonymous'] } }
);

console.log(`Modified ${result1.modifiedCount} documents where "AIAAIC" was the only submitter`);

// Remove "AIAAIC" from the `submitters` array if there are multiple elements
const result2 = await reportsCollection.updateMany(
{ submitters: 'AIAAIC' },
{ $pull: { submitters: 'AIAAIC' } }
);

console.log(
`Modified ${result2.modifiedCount} documents where "AIAAIC" was one of the submitters`
);
};

0 comments on commit 98f2d74

Please sign in to comment.