oneuptime/init-script/scripts/3.0.9318.ts
Nawaz Dhandala afd62f21ce
fix lint
2022-03-22 14:33:55 +00:00

31 lines
758 B
TypeScript

import { find, update } from '../util/db';
const subscriberCollection = 'subscribers';
async function run() {
const subscribers = await find(subscriberCollection, {
notificationType: { $exists: false },
});
for (let i = 0; i < subscribers.length; i++) {
const subscriber = subscribers[i];
let notificationType = null;
if (subscriber.statusPageId) {
notificationType = {
announcement: false,
incident: false,
scheduledEvent: false,
};
}
await update(
subscriberCollection,
{ _id: subscriber._id },
{
notificationType,
}
);
}
}
export default run;