mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-23 16:21:28 +00:00
252533b2fd
[mongo-utils] create new home for batchedUpdate helper GitOrigin-RevId: 9f61c5e367a9f4cef63b5cc4c0bbbd3ef57c8ca8
37 lines
755 B
JavaScript
37 lines
755 B
JavaScript
import { db } from '../app/src/infrastructure/mongodb.js'
|
|
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
|
|
|
const tags = ['saas']
|
|
|
|
const batchedUpdateOptions = {
|
|
VERBOSE_LOGGING: 'true',
|
|
BATCH_SIZE: '1',
|
|
}
|
|
|
|
const migrate = async () => {
|
|
await batchedUpdate(
|
|
db.users,
|
|
{ 'twoFactorAuthentication.secret': { $exists: true } },
|
|
{ $unset: { twoFactorAuthentication: true } },
|
|
null,
|
|
null,
|
|
batchedUpdateOptions
|
|
)
|
|
}
|
|
|
|
const rollback = async () => {
|
|
await batchedUpdate(
|
|
db.users,
|
|
{ 'twoFactorAuthentication.secretEncrypted': { $exists: true } },
|
|
{ $unset: { twoFactorAuthentication: true } },
|
|
null,
|
|
null,
|
|
batchedUpdateOptions
|
|
)
|
|
}
|
|
|
|
export default {
|
|
tags,
|
|
migrate,
|
|
rollback,
|
|
}
|