Fix filters (#2804)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-03-22 15:06:57 +06:00 committed by GitHub
parent 48be42610e
commit ad6eb3a84b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

View File

@ -130,6 +130,13 @@ export class LiveQuery extends TxProcessor implements Client {
if (this.client.getHierarchy().getDomain(_class) === DOMAIN_MODEL) {
return await this.client.findAll(_class, query, options)
}
if (options?.projection !== undefined) {
options.projection = {
...options.projection,
_class: 1,
modifiedOn: 1
}
}
const q = this.findQuery(_class, query, options) ?? this.createDumpQuery(_class, query, options)
if (q.result instanceof Promise) {
q.result = await q.result
@ -148,6 +155,13 @@ export class LiveQuery extends TxProcessor implements Client {
if (this.client.getHierarchy().getDomain(_class) === DOMAIN_MODEL) {
return await this.client.findOne(_class, query, options)
}
if (options?.projection !== undefined) {
options.projection = {
...options.projection,
_class: 1,
modifiedOn: 1
}
}
const q = this.findQuery(_class, query, options) ?? this.createDumpQuery(_class, query, options)
if (q.result instanceof Promise) {
q.result = await q.result
@ -255,6 +269,13 @@ export class LiveQuery extends TxProcessor implements Client {
callback: (result: FindResult<T>) => void,
options?: FindOptions<T>
): () => void {
if (options?.projection !== undefined) {
options.projection = {
...options.projection,
_class: 1,
modifiedOn: 1
}
}
const q =
this.getQuery(_class, query, callback as (result: Doc[]) => void, options) ??
this.createQuery(_class, query, callback, options)

View File

@ -70,7 +70,7 @@
}
targets.clear()
const baseObjects = await client.findAll(filter.key._class, space ? { space } : {}, {
projection: { [filter.key.key]: 1 }
projection: { [filter.key.key]: 1, space: 1 }
})
for (const object of baseObjects) {
const value = getObjectValue(filter.key.key, object) ?? undefined

View File

@ -64,7 +64,7 @@
{ ...resultQuery, ...(space ? { space } : {}) },
{
sort: { [filter.key.key]: SortingOrder.Ascending },
projection: { [prefix + filter.key.key]: 1 }
projection: { [prefix + filter.key.key]: 1, space: 1 }
}
)
const res = await objectsPromise