mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-12 15:52:04 +00:00
Merge pull request #8542 from overleaf/jlm-drop-index-if-exists
Do not fail to drop non-existent indexes GitOrigin-RevId: 226eba50a395f62751028e22030a53a0487f5343
This commit is contained in:
parent
3b84710d75
commit
a4fa86deed
1 changed files with 13 additions and 1 deletions
|
@ -15,7 +15,19 @@ async function addIndexesToCollection(collection, indexes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dropIndexesFromCollection(collection, indexes) {
|
async function dropIndexesFromCollection(collection, indexes) {
|
||||||
return Promise.all(indexes.map(index => collection.dropIndex(index.name)))
|
return Promise.all(
|
||||||
|
indexes.map(async index => {
|
||||||
|
try {
|
||||||
|
await collection.dropIndex(index.name)
|
||||||
|
} catch (err) {
|
||||||
|
if (err.code === 27 /* IndexNotFound */) {
|
||||||
|
console.log(`Index ${index.name} not found; drop was a no-op.`)
|
||||||
|
} else {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dropCollection(collectionName) {
|
async function dropCollection(collectionName) {
|
||||||
|
|
Loading…
Reference in a new issue