mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> GitOrigin-RevId: abb0bfda774dc278ae3256ee5a461240f5511461
37 lines
950 B
JavaScript
37 lines
950 B
JavaScript
import Helpers from './lib/helpers.mjs'
|
|
|
|
const tags = ['auxiliary']
|
|
|
|
// Two partial indexes (docs without trashedAt are not indexed) supporting the
|
|
// soft-delete (trash) feature
|
|
// - userId_1_trashedAt_1__id_1 serves the per-user trash listing/search,
|
|
// - trashedAt_1 serves the daily expiry cron's cross-user scan.
|
|
const newIndexes = [
|
|
{
|
|
key: { userId: 1, trashedAt: 1, _id: 1 },
|
|
name: 'userId_1_trashedAt_1__id_1',
|
|
partialFilterExpression: { trashedAt: { $exists: true } },
|
|
},
|
|
{
|
|
key: { trashedAt: 1 },
|
|
name: 'trashedAt_1',
|
|
partialFilterExpression: { trashedAt: { $exists: true } },
|
|
},
|
|
]
|
|
|
|
const migrate = async client => {
|
|
const { db } = client
|
|
await Helpers.addIndexesToCollection(db.libraryReferences, newIndexes)
|
|
}
|
|
|
|
const rollback = async client => {
|
|
const { db } = client
|
|
await Helpers.dropIndexesFromCollection(db.libraryReferences, newIndexes)
|
|
}
|
|
|
|
export default {
|
|
tags,
|
|
migrate,
|
|
rollback,
|
|
}
|