Reorder lookup fix (#1971)

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-06-01 18:13:50 +06:00 committed by GitHub
parent ae6ee89582
commit c703fbd2e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -178,7 +178,9 @@ function getKeyLookup<T extends Doc> (
const lookupClass = (attribute.type as RefTo<Doc>).to const lookupClass = (attribute.type as RefTo<Doc>).to
const index = key.indexOf('$lookup', lastIndex) const index = key.indexOf('$lookup', lastIndex)
if (index === -1) { if (index === -1) {
;(lookup as any)[attrib] = lookupClass if ((lookup as any)[attrib] === undefined) {
;(lookup as any)[attrib] = lookupClass
}
} else { } else {
let nested = Array.isArray((lookup as any)[attrib]) ? (lookup as any)[attrib][1] : {} let nested = Array.isArray((lookup as any)[attrib]) ? (lookup as any)[attrib][1] : {}
nested = getKeyLookup(hierarchy, lookupClass, key.slice(index), nested) nested = getKeyLookup(hierarchy, lookupClass, key.slice(index), nested)