TSK-1248: revert changes and add check for unset field (#3054)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2023-04-24 16:46:40 +05:00 committed by GitHub
parent c1fac81f50
commit faf6c4b055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1063,7 +1063,7 @@ function fillDateSort (key: string, pipeline: any[], sort: any, options: FindOpt
}
pipeline.push({
$addFields: {
[`sort_isNull_${key}`]: { [key]: null }
[`sort_isNull_${key}`]: { $or: [{ $eq: [`$${key}`, null] }, { $eq: [{ $type: `$${key}` }, 'missing'] }] }
}
})
sort[`sort_isNull_${key}`] = options.sort[_key] === SortingOrder.Ascending ? 1 : -1