QFix: add limit to count queries (#7458)

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko 2024-12-14 00:34:46 +07:00 committed by GitHub
parent 5b1f0a6c35
commit a122f866e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 26 additions and 10 deletions

View File

@ -106,9 +106,14 @@
const starredQuery = createQuery() const starredQuery = createQuery()
let isStarred = false let isStarred = false
$: starredQuery.query(document.class.SavedDocument, { attachedTo: _id }, (res) => { $: starredQuery.query(
isStarred = res.length !== 0 document.class.SavedDocument,
}) { attachedTo: _id },
(res) => {
isStarred = res.length !== 0
},
{ limit: 1 }
)
async function createEmbedding (file: File): Promise<{ file: Ref<Blob>, type: string } | undefined> { async function createEmbedding (file: File): Promise<{ file: Ref<Blob>, type: string } | undefined> {
if (doc === undefined) { if (doc === undefined) {

View File

@ -34,9 +34,11 @@
products.class.ProductVersion, products.class.ProductVersion,
{ space: objectId }, { space: objectId },
(res) => { (res) => {
versions = res.length versions = res.total
}, },
{ {
total: true,
limit: 1,
projection: { _id: 1 } projection: { _id: 1 }
} }
) )

View File

@ -30,9 +30,14 @@
let applications: number let applications: number
const query = createQuery() const query = createQuery()
$: query.query(recruit.class.Applicant, { space: objectId }, (res) => { $: query.query(
applications = res.length recruit.class.Applicant,
}) { space: objectId },
(res) => {
applications = res.total
},
{ total: true, limit: 1 }
)
const createApp = (ev: MouseEvent): void => { const createApp = (ev: MouseEvent): void => {
showPopup(CreateApplication, { space: objectId, preserveVacancy: true }, ev.target as HTMLElement) showPopup(CreateApplication, { space: objectId, preserveVacancy: true }, ev.target as HTMLElement)

View File

@ -47,10 +47,12 @@
core.class.TypedSpace, core.class.TypedSpace,
{ type: type._id }, { type: type._id },
(res) => { (res) => {
spacesCount = res.length spacesCount = res.total
loading = false loading = false
}, },
{ {
total: true,
limit: 1,
projection: { _id: 1 } projection: { _id: 1 }
} }
) )

View File

@ -71,9 +71,11 @@
task.class.Task, task.class.Task,
{ kind: taskType._id }, { kind: taskType._id },
(res) => { (res) => {
tasksCounter = res.length tasksCounter = res.total
}, },
{ {
total: true,
limit: 1,
projection: { projection: {
_id: 1 _id: 1
} }

View File

@ -29,7 +29,7 @@
testManagement.class.TestCase, testManagement.class.TestCase,
query, query,
(res) => { (res) => {
testCases = res.length testCases = res.total
}, },
{ total: true, limit: 1 } { total: true, limit: 1 }
) )