From 2b4f190264824019a1a18080305902c88980be41 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 20 Oct 2023 12:58:09 +0300 Subject: [PATCH] try-catch createIndex --- src/MongoDB.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/MongoDB.ts b/src/MongoDB.ts index 7f83b5e..78ea39a 100644 --- a/src/MongoDB.ts +++ b/src/MongoDB.ts @@ -409,7 +409,14 @@ class MongoDB if (existing) await this.#db.collection(collection).dropIndex(existing.name); - await this.#db.collection(collection).createIndex(index, options); + try + { + await this.#db.collection(collection).createIndex(index, options); + } + catch (err) + { + this.#logger.error(err as Error); + } } async ensureIndices (collection: string, indices: IndexSpecification[], options?: CreateIndexesOptions & StringIndexable): Promise