-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
88 lines (77 loc) · 2.79 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
export class EZindexDB {
/**
* Initializes a connection to the database or creates it if it doesn't exist.
*
* @param database - The name of the database.
* @param table - The name of the table (object store).
* @param indexes - An array of index names to be created.
* @returns Resolves to true if successful.
*/
start(database: string, table: string, indexes?: string[]): Promise<boolean>;
/**
* Adds a record to the database if it doesn't exist.
* Throws an error if the record already exists.
*
* @param table - The name of the table (object store).
* @param data - The data to be added.
* @returns Resolves to the key of the added record.
*/
creates(table: string, data: object): Promise<IDBValidKey>;
/**
* Retrieves a record from the database by its ID.
*
* @param table - The name of the table (object store).
* @param id - The ID of the record to retrieve.
* @returns Resolves to the retrieved record.
*/
reads(table: string, id: IDBValidKey): Promise<object>;
/**
* Updates an existing record in the database.
* Throws an error if the record doesn't exist.
*
* @param table - The name of the table (object store).
* @param data - The data to update.
* @returns Resolves to the key of the updated record.
*/
updates(table: string, data: object): Promise<IDBValidKey>;
/**
* Inserts or updates a record in the database.
*
* @param table - The name of the table (object store).
* @param data - The data to insert or update.
* @returns Resolves to the key of the inserted or updated record.
*/
upserts(table: string, data: object): Promise<IDBValidKey>;
/**
* Deletes a record from the database by its ID.
*
* @param table - The name of the table (object store).
* @param id - The ID of the record to delete.
* @returns Resolves to true if the deletion was successful.
*/
deletes(table: string, id: IDBValidKey): Promise<boolean>;
/**
* Searches for records in the database by a specified field and value.
*
* @param table - The name of the table (object store).
* @param field - The name of the field to search by.
* @param value - The value to search for.
* @returns Resolves to an array of matching records.
*/
searches(table: string, field: string, value: any): Promise<object[]>;
/**
* Retrieves all records from a table.
*
* @param table - The name of the table (object store).
* @returns Resolves to an array of all records.
*/
getAll(table: string): Promise<object[]>;
/**
* Counts the number of records in a table.
*
* @param table - The name of the table (object store).
* @returns Resolves to the count of records.
*/
countRecords(table: string): Promise<number>;
}
export class SynthEzIndexDB extends EZindexDB {}