forked from tmotagam/sqlite-electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlite-electron.d.ts
More file actions
149 lines (137 loc) · 5.87 KB
/
sqlite-electron.d.ts
File metadata and controls
149 lines (137 loc) · 5.87 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
138
139
140
141
142
143
144
145
146
147
148
149
/*
Types for sqlite-electron modules
Copyright (C) 2020-2025 Motagamwala Taha Arif Ali
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* setdbPath function allows for connecting to the database.
*
* @param {string} path - Relative path of a database since it constructs absolute path by itself
* @param {boolean} isuri - true if path is a URL
* @return {Promise<Boolean>} boolean
*
* @example
*
* setdbPath(path='./path/to/db/path.db')
* setdbPath(path=':memory:') // In-memory database
* setdbPath(path='file:tutorial.db?mode=ro', isuri=true) // Opening read-only database using SQLite URI
*/
export declare function setdbPath(
path: string,
isuri?: boolean
): Promise<Boolean>;
/**
* executeQuery function executes only one query.
*
* @param {string} query - SQL query
* @param {Array<string | number | null | Buffer>} values - An optional param for values used in a SQL query
* @return {Promise<Boolean>} boolean
*
* @example
*
* executeQuery(query='CREATE TABLE sqlite_master (name, email, joining_date, salary)')
* executeQuery(query='INSERT INTO sqlite_master (name, email, joining_date, salary) values(?,?,?,?)', values=['John Doe','example@sqlite-electron.com','1250-12-19',8000000])
*/
export declare function executeQuery(
query: string,
values?: Array<string | number | null | Buffer>
): Promise<Boolean>;
/**
* Fetches all the records from the database based on the given query
* and returns the result as an array of the specified type.
*
* @param {string} query the SQL query to be executed
* @param {Array<string | number | null | Buffer>} values optional array of values to be used in the query
* @return {Promise<Array<T>>} A promise that resolves to an array of objects of the specified type.
*/
export declare function fetchAll<T>(
query: string,
values?: Array<string | number | null | Buffer>
): Promise<Array<T>>;
/**
* Fetches single records from the database based on the given query
* and returns the result as an object of the specified type.
*
* @param {string} query The SQL query to execute.
* @param {Array<string | number | null | Buffer>} values Optional values to bind to the query parameters.
* @return {Promise<T>} A promise that resolves to an object of the specified type.
*/
export declare function fetchOne<T>(
query: string,
values?: Array<string | number | null | Buffer>
): Promise<T>;
/**
* Fetches multiple records from the database based on the given query
* and returns the result as an array of the specified type.
*
* @param {string} query The query to execute on the database.
* @param {number} size The number of records to fetch.
* @param {Array<string | number | null | Buffer>} values Optional values to be used in the query parameters.
* @return {Promise<Array<T>>} A promise that resolves to an array of object of the specified type.
*/
export declare function fetchMany<T>(
query: string,
size: number,
values?: Array<string | number | null | Buffer>
): Promise<Array<T>>;
/**
* executeMany function executes only one query on multiple values useful for bulk write.
*
* @param {string} query - SQL query
* @param {Array<Array<string | number | null | Buffer>>} values - A param for values used in a SQL query
* @return {Promise<Boolean>} boolean
*
* @example
*
* executeMany(query='INSERT INTO sqlite_master (name, email, joining_date, salary) values(?,?,?,?)', values=[['John Doe','example@sqlite-electron.com','1250-12-19',8000000], ['John Doe','example@sqlite-electron.com','1250-12-19',8000000]])
*/
export declare function executeMany(
query: string,
values: Array<Array<string | number | null | Buffer>>
): Promise<boolean>;
/**
* executeScript function executes all the queries given in the sql script.
*
* @param {string} scriptname - A path param for sql script or sql script itself
* @return {Promise<Boolean>} boolean
*
* @example
*
* executeScript(scriptname='C://database//script.sql')
* executeScript(scriptname='CREATE TABLE IF NOT EXISTS comp (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,NAME TEXT NOT NULL,AGE INT NOT NULL,ADDRESS CHAR(50) NOT NULL,SALARY REAL NOT NULL);')
*/
export declare function executeScript(scriptname: string): Promise<Boolean>;
/**
* load_extension function loads an extension into the database.
*
* @param {string} path - Path of the extension
* @return {Promise<Boolean>} boolean
*
* @example
*
* load_extension(path='./fts5')
*/
export declare function load_extension(path: string): Promise<Boolean>;
/**
* backup function creates a backup of the database.
*
* @param {string} target - The database connection to save the backup to.
* @param {number} pages - The number of pages to copy at a time. If equal to or less than 0, the entire database is copied in a single step. Defaults to -1.
* @param {string} name - The name of the database to back up. Either "main" (the default) for the main database, "temp" for the temporary database, or the name of a custom database as attached using the ATTACH DATABASE SQL statement.
* @param {number} sleep - The number of seconds to sleep between successive attempts to back up remaining pages.
* @return {Promise<Boolean>} boolean
*
* @example
*
* backup(target='./backup.db', pages=10, name='main', sleep=10)
*/
export declare function backup(target: string, pages?: number, name?: string, sleep?: number): Promise<Boolean>;