forked from labring/laf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccessor.ts
51 lines (42 loc) · 1.2 KB
/
accessor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Params } from "../types"
export interface ReadResult {
list: object[]
total?: number
limit?: number
offset?: number
}
export interface UpdateResult {
upsert_id: string,
updated: number,
matched: number
}
export interface AddResult {
_id: string,
insertedCount: number
}
export interface RemoveResult {
deleted: number
}
export interface CountResult {
total: number
}
export interface CreateIndexResult {
indexName: string
}
export interface DropIndexResult {
result: any
}
export interface ListIndexesResult {
list: object[]
}
export interface AccessorInterface {
type: string,
execute(params: Params): Promise<ReadResult | UpdateResult | AddResult | RemoveResult | CountResult | CreateIndexResult | DropIndexResult | ListIndexesResult>
get(collection: string, query: any): Promise<any>
close(): void
on(event: string | symbol, listener: (...args: any[]) => void): void
off(event: string | symbol, listener: (...args: any[]) => void): void
emit(event: string | symbol, ...args: any[]): boolean
once(event: string | symbol, listener: (...args: any[]) => void): void
removeAllListeners(event?: string | symbol): void
}