-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
214 lines (184 loc) · 8.43 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
/**
* quick.db definitions
*/
declare module 'quick.db' {
export interface Options {
target?: string | null;
table?: string;
}
export type ValueData = string | object | number | null | boolean | bigint | symbol | any[];
/**
* Package version. Community requested feature.
* ```
* console.log(require('quick.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 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 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 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 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 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 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,
add,
subtract,
push,
has,
includes,
all,
fetchAll,
del as delete,
dataType as type,
Table as table,
version
}
}