1 | import { IModel, IFinderOptions, IndexAction, IRepoOptions, ISearchProvider, IPlugin, IModelMapper, ISearchOptions, IRepoPlugin, IFinderPlugin, ModelPersistenceEventType, IPredicate } from "./Types";
|
2 | import { Coordinator } from './Coordinator';
|
3 | import { IModelType } from "./ModelTypes";
|
4 | import { IModelOptions, IKeyValue, TKeyValue, IModelAttributeOptions } from "./decorations/ModelDecorations";
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export declare class Repo<M extends IModel> {
|
15 | repoClazz: any;
|
16 | modelClazz: {
|
17 | new (): M;
|
18 | };
|
19 | modelOpts: IModelOptions;
|
20 | repoOpts: IRepoOptions;
|
21 | modelType: IModelType;
|
22 | mapper: any;
|
23 | coordinator: Coordinator;
|
24 | protected plugins: IPlugin[];
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | constructor(repoClazz: any, modelClazz: {
|
33 | new (): M;
|
34 | });
|
35 | protected getRepoPlugins(): IRepoPlugin<M>[];
|
36 | protected getFinderPlugins(): IFinderPlugin[];
|
37 | attr(name: string): IModelAttributeOptions;
|
38 | init(coordinator: any): void;
|
39 | start(): void;
|
40 | getMapper<M extends IModel>(clazz: {
|
41 | new (): M;
|
42 | }): IModelMapper<M>;
|
43 | /**
|
44 | * Attach a plugin to the repo - could be a store,
|
45 | * indexer, etc, etc
|
46 | *
|
47 | * @param plugin
|
48 | * @returns {Repo}
|
49 | */
|
50 | attach(plugin: IPlugin): this;
|
51 | getFinderOptions(finderKey: string): IFinderOptions;
|
52 | getPlugins: (predicate: IPredicate) => IPlugin[];
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | decorateFinder(finderKey: any): void;
|
60 | |
61 |
|
62 |
|
63 | decorateFinders(): void;
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | makeGenericFinder(finderKey: string, searchProvider: ISearchProvider, searchOpts: ISearchOptions<any>): (...args: any[]) => Promise<Promise<M>[]>;
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | protected setFinder(finderKey: string, finderFn: (...args) => any): void;
|
82 | |
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | triggerPersistenceEvent(type: ModelPersistenceEventType, ...models: any[]): void;
|
90 | supportPersistenceEvents(): boolean;
|
91 | |
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 | index(type: IndexAction, ...models: IModel[]): Promise<boolean>;
|
99 | indexPromise(action: IndexAction): (models: M[]) => Promise<M[]>;
|
100 | |
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | key(...args: any[]): IKeyValue;
|
107 | |
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | get(key: TKeyValue): Promise<M>;
|
114 | |
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 | save(o: M): Promise<M>;
|
121 | |
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 | remove(key: TKeyValue): Promise<any>;
|
128 | |
129 |
|
130 |
|
131 |
|
132 |
|
133 | count(): Promise<number>;
|
134 | bulkGet(...keys: TKeyValue[]): Promise<M[]>;
|
135 | bulkSave(...models: M[]): Promise<M[]>;
|
136 | bulkRemove(...keys: TKeyValue[]): Promise<any[]>;
|
137 | }
|