mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
parent
ccaf66f179
commit
e92918c6c7
@ -57,16 +57,23 @@
|
||||
resultQuery = { ...p, ...query }
|
||||
})
|
||||
|
||||
$: queryNoLookup = noLookup(resultQuery)
|
||||
|
||||
$: if (documents === undefined) {
|
||||
docsQuery.query(
|
||||
_class,
|
||||
noLookup(resultQuery),
|
||||
queryNoLookup,
|
||||
(res) => {
|
||||
docs = res
|
||||
},
|
||||
{
|
||||
...resultOptions,
|
||||
projection: { ...resultOptions.projection, _id: 1, _class: 1, ...getProjection(viewOptions.groupBy) }
|
||||
projection: {
|
||||
...resultOptions.projection,
|
||||
_id: 1,
|
||||
_class: 1,
|
||||
...getProjection(viewOptions.groupBy, queryNoLookup)
|
||||
}
|
||||
}
|
||||
)
|
||||
} else {
|
||||
@ -74,11 +81,14 @@
|
||||
docs = documents
|
||||
}
|
||||
|
||||
function getProjection (fields: string[]): Record<string, number> {
|
||||
function getProjection (fields: string[], query: DocumentQuery<Doc>): Record<string, number> {
|
||||
const res: Record<string, number> = {}
|
||||
for (const f of fields) {
|
||||
res[f] = 1
|
||||
}
|
||||
for (const f of Object.keys(query)) {
|
||||
res[f] = 1
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user