-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathStorageAdapter.js
More file actions
137 lines (131 loc) · 3.64 KB
/
StorageAdapter.js
File metadata and controls
137 lines (131 loc) · 3.64 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// @flow
export type SchemaType = any;
export type StorageClass = any;
export type QueryType = any;
export type QueryOptions = {
skip?: number,
limit?: number,
acl?: string[],
sort?: { [string]: number },
count?: boolean | number,
keys?: string[],
op?: string,
distinct?: boolean,
pipeline?: any,
readPreference?: ?string,
hint?: ?mixed,
explain?: Boolean,
caseInsensitive?: boolean,
action?: string,
addsField?: boolean,
comment?: string,
ignoreIncludeErrors?: boolean,
};
export type UpdateQueryOptions = {
many?: boolean,
upsert?: boolean,
};
export type FullQueryOptions = QueryOptions & UpdateQueryOptions;
export interface StorageAdapter {
canSortOnJoinTables: boolean;
schemaCacheTtl: ?number;
enableSchemaHooks: boolean;
classExists(className: string): Promise<boolean>;
setClassLevelPermissions(className: string, clps: any): Promise<void>;
createClass(className: string, schema: SchemaType): Promise<void>;
addFieldIfNotExists(className: string, fieldName: string, type: any): Promise<void>;
updateFieldOptions(className: string, fieldName: string, type: any): Promise<void>;
deleteClass(className: string): Promise<void>;
deleteAllClasses(fast: boolean): Promise<void>;
deleteFields(className: string, schema: SchemaType, fieldNames: Array<string>): Promise<void>;
getAllClasses(): Promise<StorageClass[]>;
getClass(className: string): Promise<StorageClass>;
createObject(
className: string,
schema: SchemaType,
object: any,
transactionalSession: ?any
): Promise<any>;
deleteObjectsByQuery(
className: string,
schema: SchemaType,
query: QueryType,
transactionalSession: ?any
): Promise<void>;
updateObjectsByQuery(
className: string,
schema: SchemaType,
query: QueryType,
update: any,
transactionalSession: ?any
): Promise<[any]>;
findOneAndUpdate(
className: string,
schema: SchemaType,
query: QueryType,
update: any,
transactionalSession: ?any
): Promise<any>;
upsertOneObject(
className: string,
schema: SchemaType,
query: QueryType,
update: any,
transactionalSession: ?any
): Promise<any>;
find(
className: string,
schema: SchemaType,
query: QueryType,
options: QueryOptions
): Promise<[any]>;
ensureIndex(
className: string,
schema: SchemaType,
fieldNames: string[],
indexName?: string,
caseSensitive?: boolean,
options?: Object
): Promise<any>;
ensureUniqueness(className: string, schema: SchemaType, fieldNames: Array<string>): Promise<void>;
count(
className: string,
schema: SchemaType,
query: QueryType,
readPreference?: string,
estimate?: boolean,
hint?: mixed,
comment?: string
): Promise<number>;
distinct(
className: string,
schema: SchemaType,
query: QueryType,
fieldName: string
): Promise<any>;
aggregate(
className: string,
schema: any,
pipeline: any,
readPreference: ?string,
hint: ?mixed,
explain?: boolean,
comment?: string
): Promise<any>;
performInitialization(options: ?any): Promise<void>;
watch(callback: () => void): void;
// Indexing
createIndexes(className: string, indexes: any, conn: ?any): Promise<void>;
getIndexes(className: string, connection: ?any): Promise<void>;
updateSchemaWithIndexes(): Promise<void>;
setIndexesWithSchemaFormat(
className: string,
submittedIndexes: any,
existingIndexes: any,
fields: any,
conn: ?any
): Promise<void>;
createTransactionalSession(): Promise<any>;
commitTransactionalSession(transactionalSession: any): Promise<void>;
abortTransactionalSession(transactionalSession: any): Promise<void>;
}