mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
New index for querying items in a users synced collection
GitOrigin-RevId: aa81ca46cdd238a46a8002d1c991da787c1b9b0f
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import Helpers from './lib/helpers.mjs'
|
||||
|
||||
const tags = ['saas']
|
||||
|
||||
// Supports the moved-out-of-collection diff: for a synced collection, find
|
||||
// every locally-recorded item whose cached membership includes that
|
||||
// collection key, projected down to just itemKey/collections (see
|
||||
// findZoteroCollectionMembership in LibraryReferenceRepository.mts).
|
||||
const newIndexes = [
|
||||
{
|
||||
key: {
|
||||
userId: 1,
|
||||
'sources.zotero.libraryType': 1,
|
||||
'sources.zotero.libraryId': 1,
|
||||
'sources.zotero.collections': 1,
|
||||
},
|
||||
name: 'userId_1_sources.zotero.libraryType_1_sources.zotero.libraryId_1_sources.zotero.collections_1',
|
||||
partialFilterExpression: { 'sources.zotero.itemKey': { $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,
|
||||
}
|
||||
Reference in New Issue
Block a user