mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Add auxiliary Mongo cluster support for library collections GitOrigin-RevId: 1cfdbe4bbeb6c95f1158834ae60a4e34bef7bb87
37 lines
950 B
JavaScript
37 lines
950 B
JavaScript
import Helpers from './lib/helpers.mjs'
|
|
|
|
const tags = ['saas', 'auxiliary']
|
|
|
|
// Partial indexes so docs without a given match token are not indexed. They
|
|
// back the batch duplicate-detection query in findMatchingReferences.
|
|
const newIndexes = [
|
|
{
|
|
key: { userId: 1, 'matchTokens.doi': 1 },
|
|
name: 'userId_1_matchTokens.doi_1',
|
|
partialFilterExpression: { 'matchTokens.doi': { $exists: true } },
|
|
},
|
|
{
|
|
key: { userId: 1, 'matchTokens.authorTitleYear': 1 },
|
|
name: 'userId_1_matchTokens.authorTitleYear_1',
|
|
partialFilterExpression: {
|
|
'matchTokens.authorTitleYear': { $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,
|
|
}
|