This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
types.ts
52 lines (41 loc) · 1.55 KB
/
types.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
52
import { logger } from "@truffle/db/logger";
const debug = logger("db:meta:pouch:types");
import PouchDB from "pouchdb";
import type { Collections, CollectionName } from "@truffle/db/meta/collections";
import type * as Id from "@truffle/db/meta/id";
export type History = PouchDB.Core.IdMeta & PouchDB.Core.GetMeta;
export type Historical<T> = T & History;
export interface Adapter<C extends Collections> {
every<N extends CollectionName<C>, I extends PouchDB.Core.IdMeta>(
collectionName: N
): Promise<Historical<I>[]>;
retrieve<N extends CollectionName<C>, I extends PouchDB.Core.IdMeta>(
collectionName: N,
references: (Pick<I, "_id"> | undefined)[]
): Promise<(Historical<I> | undefined)[]>;
search<N extends CollectionName<C>, I extends PouchDB.Core.IdMeta>(
collectionName: N,
options: PouchDB.Find.FindRequest<{}>
): Promise<Historical<I>[]>;
record<N extends CollectionName<C>, I extends PouchDB.Core.IdMeta>(
collectionName: N,
inputs: (I | undefined)[],
options: { overwrite?: boolean }
): Promise<(Historical<I> | undefined)[]>;
forget<N extends CollectionName<C>, I extends PouchDB.Core.IdMeta>(
collectionName: N,
references: (Pick<I, "_id"> | undefined)[]
): Promise<void>;
}
/**
* @category Definitions
*/
export type Definitions<C extends Collections> = {
[N in CollectionName<C>]: Definition<C, N>;
};
/**
* @category Definitions
*/
export type Definition<C extends Collections, N extends CollectionName<C>> = {
createIndexes: PouchDB.Find.CreateIndexOptions["index"][];
} & Id.Definition<C, N>;