Refresh query over limit (#2142)

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-06-24 14:58:52 +06:00 committed by GitHub
parent 6c3070c85d
commit 016a2c58ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -342,8 +342,12 @@ export class LiveQuery extends TxProcessor implements Client {
if (q.query.$search != null && q.query.$search.length > 0) {
const match = await this.findOne(q._class, { $search: q.query.$search, _id: tx.objectId }, q.options)
if (match === undefined) {
if (q.options?.limit === q.result.length) {
return await this.refresh(q)
} else {
q.result.splice(pos, 1)
q.total--
}
} else {
q.result[pos] = match
}
@ -354,15 +358,23 @@ export class LiveQuery extends TxProcessor implements Client {
const current = await this.findOne(q._class, { _id: updatedDoc._id }, q.options)
if (current !== undefined) {
q.result[pos] = current
} else {
if (q.options?.limit === q.result.length) {
return await this.refresh(q)
} else {
q.result.splice(pos, 1)
q.total--
}
}
} else {
await this.__updateDoc(q, updatedDoc, tx)
if (!this.match(q, updatedDoc)) {
if (q.options?.limit === q.result.length) {
return await this.refresh(q)
} else {
q.result.splice(pos, 1)
q.total--
}
} else {
q.result[pos] = updatedDoc
}