-
Notifications
You must be signed in to change notification settings - Fork 1
/
harpee-model.interface.ts
197 lines (190 loc) · 4.77 KB
/
harpee-model.interface.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import { Order, StringOrNumber } from './harpee.interface';
export type IHarpeeModelFindOptions = {
/**
*
* the number of records that the query result will include,default is `null`, resulting in no limit
*/
limit?: number;
/**
* the number of records that the query will skip
*/
offset?: number;
/**
* columns to order the result
*/
orderby?: string[];
/**
* the order of the result, 'desc' or 'asc'
*/
order?: Order;
where?: string;
and?: string | number;
getAttributes?: string[];
};
export interface IHarperDBCRUDResponse {
message: string;
update_hashes: StringOrNumber[];
skipped_hashes: StringOrNumber[];
inserted_hashes: StringOrNumber[];
deleted_hashes: StringOrNumber[];
}
export type IHarperDBDeleteResponse = Pick<
IHarperDBCRUDResponse,
'deleted_hashes' | 'skipped_hashes' | 'message'
>;
export type IHarperDBUpdateResponse = Pick<
IHarperDBCRUDResponse,
'update_hashes' | 'skipped_hashes' | 'message'
>;
export type IHarperDBInsertResponse = Pick<
IHarperDBCRUDResponse,
'inserted_hashes' | 'skipped_hashes' | 'message'
>;
export interface IHarpeeModelFindByIdOptions {
id: StringOrNumber[];
getAttributes?: string[];
limit?: number;
}
export type IHarperDBS3Options = {
/**
* what action to be performed on the data. default 'insert'
*/
action?: Actions;
/**
* the name of the bucket where your file lives.
*/
bucket: string;
/**
* your aws access key id
*/
awsAccessKeyId: string;
/**
* the name of the file to import - *the file must include a valid file extension ('.csv' or '.json')*.
*/
key: string;
/**
* your aws secret access key.
*/
awsSecretAccessKey: string;
};
export type IHarpeeModelImportOptions = {
/**
* what action to be performed on the data. default 'insert'
*/
action?: Actions;
/**
a valid CSV string.
*/
csv: string;
/**
* an absolute path to the local file. **Note: this operation only works for local instances not for cloud instances**.
*/
filePath: string;
/**
* an absolute path to the external file.
*/
csvUrl: string;
/**
* selects whether or not the data load will transact to any clustered instance. The default is `false`.
*/
transactToCluster?: boolean;
};
export type IHarpeeModelUpdateNestedOptions<V = object> = {
/**
*
*/
id: StringOrNumber;
/**
* a string or array of string indicating the path to a value
* @example
* '.author.name'
* // or
* ['author','name']
*
*/
path: string | string[];
value: any | ((val: V) => V);
/**
* when true, returns the updated data, default is true
*/
returnData?: boolean;
getAttributes?: string[];
};
/**
* a string or array of string indicating the path to a value
*
*/
export type IHarpeeModelImportCsvOptions = Pick<
IHarpeeModelImportOptions,
'action' | 'csv' | 'transactToCluster'
>;
export type IHarpeeModelImportCsvFileOptions = Pick<
IHarpeeModelImportOptions,
'action' | 'filePath' | 'transactToCluster'
>;
export type IHarpeeModelImportCsvUrlOptions = Pick<
IHarpeeModelImportOptions,
'action' | 'csvUrl' | 'transactToCluster'
>;
export type Actions = 'insert' | 'update' | 'upsert';
export type Operators = 'and' | 'or';
export interface IHarpeeModelFindByValueOptions {
/**
* attribute you wish to search, can be any attribute.
*/
searchAttribute: string;
/**
* value you wish to search - wild cards are allowed..
*/
searchValue: StringOrNumber;
/**
* an array of one or more attributes to be returned, default is `["*"]` which returns all attributes.
*/
getAttributes?: string | string[];
}
export type IHarpeeModelFindByConditionOptions = {
/**
* the operator used between each condition, default is `and`
*/
operator?: Operators;
/**
* the number of records that the query will skip, default `0`
*/
offset?: number;
/**
* the number of records that the query result will include,default is `null`, resulting in no limit
*/
limit?: number | null;
/**
* the array of condition objects, must include one or more object in the array
*/
conditions: ISearchCondition[];
/**
* an array of one or more attributes to be returned, default is `["*"]` which returns all attributes.
*/
getAttributes?: string[];
};
export type ISearchCondition = {
/**
* attribute you wish to search, can be any attribute.
*/
search_attribute: string;
/**
* value you wish to search. if the search_type is `between` then use an array of two values to search between
*/
search_value: StringOrNumber;
/**
* the type of search to perform
*/
search_type: SearchType;
};
export type SearchType =
| 'equals'
| 'contains'
| 'starts_with'
| 'ends_with'
| 'greater_than'
| 'greater_than_equal'
| 'less_than'
| 'less_than_equal'
| 'between';