Minor fixes (#4454)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-01-25 22:41:27 +06:00 committed by GitHub
parent 04bb92da07
commit 78173c6acb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -511,7 +511,7 @@ export function cutObjectArray (obj: any): any {
} else Object.assign(r, { [key]: obj[key] })
continue
}
if (typeof obj[key] === 'object') {
if (typeof obj[key] === 'object' && obj[key] !== null) {
Object.assign(r, { [key]: cutObjectArray(obj[key]) })
continue
}

View File

@ -279,7 +279,12 @@ async function createUpdateIndexes (connection: CoreClient, db: Db, logger: Mode
const bb: (string | FieldIndex<Doc>)[] = []
for (const vv of v.values()) {
try {
await collection.createIndex(vv)
const key = typeof vv === 'string' ? vv : Object.keys(vv)[0]
const name = typeof vv === 'string' ? `${key}_1` : `${key}_${vv[key]}`
const exists = await collection.indexExists(name)
if (!exists) {
await collection.createIndex(vv)
}
} catch (err: any) {
logger.log('error', JSON.stringify(err))
}