This commit is contained in:
Denis Bykhov 2023-10-06 19:32:33 +06:00 committed by GitHub
parent 8392eb9b58
commit daec3b8e17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -543,6 +543,14 @@ export class LiveQuery extends TxProcessor implements Client {
await this.sort(q, tx)
const udoc = q.result.find((p) => p._id === tx.objectId)
await this.updatedDocCallback(udoc, q)
} else if (
this.client.getHierarchy().isDerived(tx.objectClass, q._class) &&
q.options?.total === true &&
q.options.limit === q.result.length
) {
// we can make object is not matching criteria, but it can be in not limited results, total can be changed
await this.refresh(q)
return
}
await this.handleDocUpdateLookup(q, tx)
}
@ -632,7 +640,7 @@ export class LiveQuery extends TxProcessor implements Client {
private async refresh (q: Query): Promise<void> {
const res = await this.client.findAll(q._class, q.query, q.options)
if (!deepEqual(res, q.result)) {
if (!deepEqual(res, q.result) || (res.total !== q.total && q.options?.total === true)) {
q.result = res
q.total = res.total
await this.callback(q)

View File

@ -562,6 +562,9 @@ abstract class MongoAdapterBase implements DbAdapter {
cursor.maxAwaitTimeMS(30000)
const res = await cursor.toArray()
if (options?.total === true && options?.limit === undefined) {
total = res.length
}
return toFindResult(res, total)
}