mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
FindOne Fix (#847)
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
626ece4045
commit
ea19fe2bbf
@ -84,7 +84,7 @@ class ClientImpl implements Client {
|
||||
query: DocumentQuery<T>,
|
||||
options?: FindOptions<T>
|
||||
): Promise<WithLookup<T> | undefined> {
|
||||
return (await this.findAll(_class, query, options))[0]
|
||||
return (await this.findAll(_class, query, { ...options, limit: 1 }))[0]
|
||||
}
|
||||
|
||||
async tx (tx: Tx): Promise<TxResult> {
|
||||
|
@ -35,8 +35,8 @@ export class TxOperations implements Omit<Client, 'notify'> {
|
||||
return this.client.findAll(_class, query, options)
|
||||
}
|
||||
|
||||
async findOne <T extends Doc>(_class: Ref<Class<T>>, query: DocumentQuery<T>, options?: FindOptions<T> | undefined): Promise<WithLookup<T> | undefined> {
|
||||
return (await this.findAll(_class, query, options))[0]
|
||||
findOne <T extends Doc>(_class: Ref<Class<T>>, query: DocumentQuery<T>, options?: FindOptions<T> | undefined): Promise<WithLookup<T> | undefined> {
|
||||
return this.client.findOne(_class, query, options)
|
||||
}
|
||||
|
||||
tx (tx: Tx): Promise<TxResult> {
|
||||
|
@ -109,7 +109,7 @@ export class LiveQuery extends TxProcessor implements Client {
|
||||
query: DocumentQuery<T>,
|
||||
options?: FindOptions<T>
|
||||
): Promise<WithLookup<T> | undefined> {
|
||||
return (await this.findAll(_class, query, options))[0]
|
||||
return await this.client.findOne(_class, query, options)
|
||||
}
|
||||
|
||||
query<T extends Doc>(
|
||||
@ -285,7 +285,7 @@ export class LiveQuery extends TxProcessor implements Client {
|
||||
for (const key in lookup) {
|
||||
const _class = (lookup as any)[key] as Ref<Class<Doc>>
|
||||
const _id = (doc as any)[key] as Ref<Doc>
|
||||
;(result as any)[key] = (await this.client.findAll(_class, { _id }))[0]
|
||||
;(result as any)[key] = await this.client.findOne(_class, { _id })
|
||||
}
|
||||
;(doc as WithLookup<Doc>).$lookup = result
|
||||
}
|
||||
|
@ -56,7 +56,7 @@
|
||||
onDestroy(
|
||||
location.subscribe(async (loc) => {
|
||||
currentApp = loc.path[1] as Ref<Application>
|
||||
currentApplication = (await client.findAll(workbench.class.Application, { _id: currentApp }))[0]
|
||||
currentApplication = await client.findOne(workbench.class.Application, { _id: currentApp })
|
||||
navigatorModel = currentApplication?.navigatorModel
|
||||
const currentFolder = loc.path[2] as Ref<Space>
|
||||
ownSpecialComponent = getOwnSpecialComponent(currentFolder)
|
||||
@ -71,7 +71,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
const space = (await client.findAll(core.class.Space, { _id: currentFolder }))[0]
|
||||
const space = await client.findOne(core.class.Space, { _id: currentFolder })
|
||||
currentSpace = currentFolder
|
||||
if (space) {
|
||||
const spaceClass = client.getHierarchy().getClass(space._class) // (await client.findAll(core.class.Class, { _id: space._class }))[0]
|
||||
|
Loading…
Reference in New Issue
Block a user