mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-11 12:17:44 +02:00
UBERF-7543: Add low level groupBy api and improve security space lookup (#6126)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -112,6 +112,8 @@ export interface DbAdapter {
|
||||
upload: (ctx: MeasureContext, domain: Domain, docs: Doc[]) => Promise<void>
|
||||
clean: (ctx: MeasureContext, domain: Domain, docs: Ref<Doc>[]) => Promise<void>
|
||||
|
||||
groupBy: <T>(ctx: MeasureContext, domain: Domain, field: string) => Promise<Set<T>>
|
||||
|
||||
// Bulk update operations
|
||||
update: (ctx: MeasureContext, domain: Domain, operations: Map<Ref<Doc>, DocumentUpdate<Doc>>) => Promise<void>
|
||||
}
|
||||
|
||||
@@ -74,6 +74,10 @@ export class DummyDbAdapter implements DbAdapter {
|
||||
async clean (ctx: MeasureContext, domain: Domain, docs: Ref<Doc>[]): Promise<void> {}
|
||||
|
||||
async update (ctx: MeasureContext, domain: Domain, operations: Map<Ref<Doc>, DocumentUpdate<Doc>>): Promise<void> {}
|
||||
|
||||
async groupBy<T>(ctx: MeasureContext, domain: Domain, field: string): Promise<Set<T>> {
|
||||
return new Set()
|
||||
}
|
||||
}
|
||||
|
||||
class InMemoryAdapter extends DummyDbAdapter implements DbAdapter {
|
||||
|
||||
@@ -117,6 +117,12 @@ class PipelineImpl implements Pipeline {
|
||||
: await this.storage.findAll(ctx.ctx, _class, query, options)
|
||||
}
|
||||
|
||||
async groupBy<T>(ctx: MeasureContext, domain: Domain, field: string): Promise<Set<T>> {
|
||||
return this.head !== undefined
|
||||
? await this.head.groupBy(ctx, domain, field)
|
||||
: await this.storage.groupBy(ctx, domain, field)
|
||||
}
|
||||
|
||||
async searchFulltext (ctx: SessionContext, query: SearchQuery, options: SearchOptions): Promise<SearchResult> {
|
||||
return this.head !== undefined
|
||||
? await this.head.searchFulltext(ctx, query, options)
|
||||
|
||||
@@ -440,6 +440,10 @@ export class TServerStorage implements ServerStorage {
|
||||
return this.model.filter((it) => it.modifiedOn > lastModelTx)
|
||||
}
|
||||
|
||||
async groupBy<T>(ctx: MeasureContext, domain: Domain, field: string): Promise<Set<T>> {
|
||||
return await this.getAdapter(domain, false).groupBy(ctx, domain, field)
|
||||
}
|
||||
|
||||
async findAll<T extends Doc>(
|
||||
ctx: MeasureContext,
|
||||
clazz: Ref<Class<T>>,
|
||||
|
||||
@@ -97,6 +97,8 @@ export interface Middleware {
|
||||
query: DocumentQuery<T>,
|
||||
options?: FindOptions<T>
|
||||
) => Promise<FindResult<T>>
|
||||
|
||||
groupBy: <T>(ctx: MeasureContext, domain: Domain, field: string) => Promise<Set<T>>
|
||||
handleBroadcast: HandleBroadcastFunc
|
||||
searchFulltext: (ctx: SessionContext, query: SearchQuery, options: SearchOptions) => Promise<SearchResult>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user