mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
Add cursor-based pagination to GET /library/references GitOrigin-RevId: 1acec69031b0ca82ef6e1e05eddb165acaf05003
32 lines
729 B
JavaScript
32 lines
729 B
JavaScript
import Helpers from './lib/helpers.mjs'
|
|
|
|
const tags = ['saas']
|
|
|
|
const oldIndex = {
|
|
key: { userId: 1, updatedAt: 1 },
|
|
name: 'userId_1_updatedAt_1',
|
|
}
|
|
|
|
const newIndex = {
|
|
key: { userId: 1, updatedAt: 1, _id: 1 },
|
|
name: 'userId_1_updatedAt_1__id_1',
|
|
}
|
|
|
|
const migrate = async client => {
|
|
const { db } = client
|
|
await Helpers.addIndexesToCollection(db.libraryReferences, [newIndex])
|
|
await Helpers.dropIndexesFromCollection(db.libraryReferences, [oldIndex])
|
|
}
|
|
|
|
const rollback = async client => {
|
|
const { db } = client
|
|
await Helpers.addIndexesToCollection(db.libraryReferences, [oldIndex])
|
|
await Helpers.dropIndexesFromCollection(db.libraryReferences, [newIndex])
|
|
}
|
|
|
|
export default {
|
|
tags,
|
|
migrate,
|
|
rollback,
|
|
}
|