mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-21 15:59:15 +00:00
Fix filters (#2804)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
48be42610e
commit
ad6eb3a84b
@ -130,6 +130,13 @@ export class LiveQuery extends TxProcessor implements Client {
|
|||||||
if (this.client.getHierarchy().getDomain(_class) === DOMAIN_MODEL) {
|
if (this.client.getHierarchy().getDomain(_class) === DOMAIN_MODEL) {
|
||||||
return await this.client.findAll(_class, query, options)
|
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)
|
const q = this.findQuery(_class, query, options) ?? this.createDumpQuery(_class, query, options)
|
||||||
if (q.result instanceof Promise) {
|
if (q.result instanceof Promise) {
|
||||||
q.result = await q.result
|
q.result = await q.result
|
||||||
@ -148,6 +155,13 @@ export class LiveQuery extends TxProcessor implements Client {
|
|||||||
if (this.client.getHierarchy().getDomain(_class) === DOMAIN_MODEL) {
|
if (this.client.getHierarchy().getDomain(_class) === DOMAIN_MODEL) {
|
||||||
return await this.client.findOne(_class, query, options)
|
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)
|
const q = this.findQuery(_class, query, options) ?? this.createDumpQuery(_class, query, options)
|
||||||
if (q.result instanceof Promise) {
|
if (q.result instanceof Promise) {
|
||||||
q.result = await q.result
|
q.result = await q.result
|
||||||
@ -255,6 +269,13 @@ export class LiveQuery extends TxProcessor implements Client {
|
|||||||
callback: (result: FindResult<T>) => void,
|
callback: (result: FindResult<T>) => void,
|
||||||
options?: FindOptions<T>
|
options?: FindOptions<T>
|
||||||
): () => void {
|
): () => void {
|
||||||
|
if (options?.projection !== undefined) {
|
||||||
|
options.projection = {
|
||||||
|
...options.projection,
|
||||||
|
_class: 1,
|
||||||
|
modifiedOn: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
const q =
|
const q =
|
||||||
this.getQuery(_class, query, callback as (result: Doc[]) => void, options) ??
|
this.getQuery(_class, query, callback as (result: Doc[]) => void, options) ??
|
||||||
this.createQuery(_class, query, callback, options)
|
this.createQuery(_class, query, callback, options)
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
}
|
}
|
||||||
targets.clear()
|
targets.clear()
|
||||||
const baseObjects = await client.findAll(filter.key._class, space ? { space } : {}, {
|
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) {
|
for (const object of baseObjects) {
|
||||||
const value = getObjectValue(filter.key.key, object) ?? undefined
|
const value = getObjectValue(filter.key.key, object) ?? undefined
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
{ ...resultQuery, ...(space ? { space } : {}) },
|
{ ...resultQuery, ...(space ? { space } : {}) },
|
||||||
{
|
{
|
||||||
sort: { [filter.key.key]: SortingOrder.Ascending },
|
sort: { [filter.key.key]: SortingOrder.Ascending },
|
||||||
projection: { [prefix + filter.key.key]: 1 }
|
projection: { [prefix + filter.key.key]: 1, space: 1 }
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const res = await objectsPromise
|
const res = await objectsPromise
|
||||||
|
Loading…
Reference in New Issue
Block a user