This repository has been archived by the owner on Feb 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
284 lines (244 loc) · 11.1 KB
/
index.d.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
declare module 'quick.db' {
export interface Options {
target?: string | null;
table?: string;
}
export interface OptionsStartsWith extends Options {
sort?: string;
limit?: number;
}
export type ValueData = string | object | number | null | boolean | bigint | symbol | any[];
export interface Many {
key: string;
value: ValueData;
}
/**
* Package version. Community requested feature.
* ```
* const db = require("quick.db-prototypes")(require("quick.db"));
* console.log(db.version);
* ```
*/
const version: string;
/**
* This function fetches data from a key in the database.
* @param key Any string as a key. Also allows for dot notation following the key.
* @param ops Any options to be added to the request.
*/
function fetch(key: string, ops?: Options): any;
/**
* This function fetches data from a key in the database.
* @param key Any string as a key. Also allows for dot notation following the key.
* @param ops Any options to be added to the request.
*/
function get(key: string, ops?: Options): any;
/**
* This function sets new data based on a key in the database.
* @param key Any string as a key. Also allows for dot notation following the key.
* @param value Value to set.
* @param ops Any options to be added to the request.
*/
function set(key: string, value: ValueData, ops?: Options): any;
/**
* This method inserts multiple data at once
* @param items Items to insert
* @param ops Any options to be added to the request.
*/
function setMany(items: Many[], ops?: Options): Many[];
/**
* This function adds a number to a key in the database. (If no existing number, it will add to 0)
* @param key Any string as a key. Also allows for dot notation following the key.
* @param value Any numerical value.
* @param ops Any options to be added to the request.
*/
function add(key: string, value: number, ops?: Options): any;
/**
* This function subtracts a number to a key in the database. (If no existing number, it will subtract from 0)
* @param key Any string as a key. Also allows for dot notation following the key.
* @param value Any numerical value.
* @param ops Any options to be added to the request.
*/
function subtract(key: string, value: number, ops?: Options): any;
/**
* This function will push into an array in the database based on the key. (If no existing array, it will create one)
* @param key Any string as a key. Also allows for dot notation following the key.
* @param value Any data to push.
* @param ops Any options to be added to the request.
*/
function push(key: string, value: ValueData, ops?: Options): any[];
/**
* This function will pull all matching data from the Array.
* @param key Any string as a key. Also allows for dot notation following the key.
* @param value Any data to pull.
* @param ops Any options to be added to the request.
*/
function pull(key: string, value: ValueData, ops?: Options): any[];
/**
* This function returns a boolean indicating whether an element with the specified key exists or not.
* @param key Any string as a key. Also allows for dot notation following the key, this will return if the prop exists or not.
* @param ops Any options to be added to the request.
*/
function has(key: string, ops?: Options): boolean;
/**
* This function returns a boolean indicating whether an element with the specified key exists or not.
* @param key Any string as a key. Also allows for dot notation following the key, this will return if the prop exists or not.
* @param ops Any options to be added to the request.
*/
function includes(key: string, ops?: Options): boolean;
/**
* This function fetches the entire active table
* @param ops Any options to be added to the request.
*/
function all(ops?: Options): { ID: string; data: any; }[];
/**
* This function fetches the entire active table
* @param ops Any options to be added to the request.
*/
function fetchAll(ops?: Options): { ID: string; data: any; }[];
/**
* This method deletes entire table or specific keys
* @param key Key to remove (optional)
* @param ops Any options to be added to the request
*/
function deleteAll(key?: string, ops?: Options): boolean;
/**
* This method can be used to get array of data with the keys that start with the given key.
* @param key Any string as a key. Also allows for dot notation following the key, this will return if the prop exists or not.
* @param ops Any options to be added to the request.
*/
function startsWith(key: string, ops?: OptionsStartsWith): { ID: string; data: any; }[];
/**
* This function will delete an object (or property) in the database.
* @param key Any string as a key. Also allows for dot notation following the key, this will delete the prop in the object.
* @param ops Any options to be added to the request.
*/
function del(key: string, ops?: Options): boolean;
/**
* Used to get the type of the value.
* @param key Any string as a key. Also allows for dot notation following the key, this will delete the prop in the object.
* @param ops Any options to be added to the request.
*/
function dataType(key: string, ops?: Options): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
class Table {
tableName: string;
/**
* Using 'new' on this function creates a new instance of a table.
* @param tableName Any string as the name of the table.
* @param options Options
*/
public constructor(tableName: string, options?: object);
/**
* This function sets new data based on a key in the database.
* @param key Any string as a key. Also allows for dot notation following the key.
* @param value Value to set.
* @param ops Any options to be added to the request.
*/
public set(key: string, value: ValueData, ops?: Options): any;
/**
* This method inserts multiple data at once
* @param items Items to insert
* @param ops Any options to be added to the request.
*/
public setMany(items: Many[], ops?: Options): Many[];
/**
* This function fetches data from a key in the database.
* @param key Any string as a key. Also allows for dot notation following the key.
* @param ops Any options to be added to the request.
*/
public get(key: string, ops?: Options): any;
/**
* This function fetches data from a key in the database.
* @param key Any string as a key. Also allows for dot notation following the key.
* @param ops Any options to be added to the request.
*/
public fetch(key: string, ops?: Options): any;
/**
* This function adds a number to a key in the database. (If no existing number, it will add to 0)
* @param key Any string as a key. Also allows for dot notation following the key.
* @param value Any numerical value.
* @param ops Any options to be added to the request.
*/
public add(key: string, value: number, ops?: Options): any;
/**
* This function subtracts a number to a key in the database. (If no existing number, it will subtract from 0)
* @param key Any string as a key. Also allows for dot notation following the key.
* @param value Any numerical value.
* @param ops Any options to be added to the request.
*/
public subtract(key: string, value: number, ops?: Options): any;
/**
* This function will push into an array in the database based on the key. (If no existing array, it will create one)
* @param key Any string as a key. Also allows for dot notation following the key.
* @param value Any data to push.
* @param ops Any options to be added to the request.
*/
public push(key: string, value: ValueData, ops?: Options): any[];
/**
* This function will pull all matching data from the Array.
* @param key Any string as a key. Also allows for dot notation following the key.
* @param value Any data to pull.
* @param ops Any options to be added to the request.
*/
public pull(key: string, value: ValueData, ops?: Options): any[];
/**
* This function returns a boolean indicating whether an element with the specified key exists or not.
* @param key Any string as a key. Also allows for dot notation following the key, this will return if the prop exists or not.
* @param ops Any options to be added to the request.
*/
public has(key: string, ops?: Options): boolean;
/**
* This function returns a boolean indicating whether an element with the specified key exists or not.
* @param key Any string as a key. Also allows for dot notation following the key, this will return if the prop exists or not.
* @param ops Any options to be added to the request.
*/
public includes(key: string, ops?: Options): boolean;
/**
* This function fetches the entire active table
* @param ops Any options to be added to the request.
*/
public all(ops?: Options): { ID: string; data: any }[];
/**
* This function fetches the entire active table
* @param ops Any options to be added to the request.
*/
public fetchAll(ops?: Options): { ID: string; data: any }[];
/**
* This method deletes entire table or specific keys
* @param key Key to remove (optional)
* @param ops Any options to be added to the request
*/
public deleteAll(key?: string, ops?: Options): boolean;
/**
* This method can be used to get array of data with the keys that start with the given key.
* @param key Any string as a key. Also allows for dot notation following the key, this will return if the prop exists or not.
* @param ops Any options to be added to the request.
*/
public startsWith(key: string, ops?: OptionsStartsWith): { ID: string; data: any }[];
/**
* This function will delete an object (or property) in the database.
* @param key Any string as a key. Also allows for dot notation following the key, this will delete the prop in the object.
* @param ops Any options to be added to the request.
*/
public delete(key: string, ops?: Options): boolean;
}
export {
fetch,
get,
set,
setMany,
add,
subtract,
push,
pull,
has,
includes,
all,
fetchAll,
deleteAll,
startsWith,
del as delete,
dataType as type,
Table as table,
version
}
}