-
Notifications
You must be signed in to change notification settings - Fork 4
/
Adapter.ts
36 lines (35 loc) · 1017 Bytes
/
Adapter.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
export interface IConnectedResult {
connected: boolean;
error?: any;
}
export type IInsertManyResponse = Promise<{
insertedCount: number;
insertedIds: Array<string>;
}>;
export interface IAdapter {
checkConnection(): Promise<IConnectedResult>;
close(): void;
count(collection: string, query: any): Promise<number>;
create(collection: string, data: any): Promise<{ [key: string]: any }>;
delete(collection: string, id: any): Promise<number>;
deleteMany(collection: string, query: any): Promise<number>;
drop(collection: string): Promise<number>;
fetch(opts: {
collection: string;
limit?: number;
query: any;
skip?: number;
sort?: any;
}): Promise<{ [key: string]: any }[]>;
generateId(): any;
insertMany(
collection: string,
docs: Array<Record<string, any>>
): IInsertManyResponse;
update(collection: string, id: any, data: any): Promise<number>;
updateMany(
collection: string,
query: any,
data: Record<string, any>
): Promise<number>;
}