@tmlmobilidade/go-clients-sqlite 20260905.1222.34 → 20260905.2252.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sqlite-db.d.ts +14 -1
- package/dist/sqlite-db.js +13 -0
- package/package.json +1 -1
package/dist/sqlite-db.d.ts
CHANGED
|
@@ -64,11 +64,24 @@ export declare class SQLiteTableInstance<T> {
|
|
|
64
64
|
* @returns True if the row exists, false otherwise.
|
|
65
65
|
*/
|
|
66
66
|
has<K extends keyof T>(col: K, value: T[K]): boolean;
|
|
67
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Execute a query and return the result as an array of rows.
|
|
69
|
+
* @param sqlQuery The SQL query to execute.
|
|
70
|
+
* @param params The parameters for the query.
|
|
71
|
+
* @returns The result as an array of rows.
|
|
72
|
+
*/
|
|
73
|
+
query<R>(sqlQuery?: string, params?: (boolean | number | string)[]): R[];
|
|
68
74
|
/**
|
|
69
75
|
* Iterator to go through all rows in the table.
|
|
70
76
|
*/
|
|
71
77
|
stream(whereClause?: string, params?: (boolean | number | string)[]): Readable;
|
|
78
|
+
/**
|
|
79
|
+
* Update one or more rows in the table.
|
|
80
|
+
* @param whereClause The WHERE clause to filter the rows to update.
|
|
81
|
+
* @param newData The data to update the rows with.
|
|
82
|
+
* @param params The parameters for the WHERE clause.
|
|
83
|
+
* @returns The updated rows.
|
|
84
|
+
*/
|
|
72
85
|
update(whereClause: string, newData: Partial<T>, params?: (boolean | number | string)[]): T[];
|
|
73
86
|
/**
|
|
74
87
|
* Add one item to buffer, flush automatically when batchSize reached.
|
package/dist/sqlite-db.js
CHANGED
|
@@ -176,6 +176,12 @@ export class SQLiteTableInstance {
|
|
|
176
176
|
const sql = `SELECT 1 FROM ${this.tableName} WHERE ${String(col)} = ? LIMIT 1`;
|
|
177
177
|
return !!this.databaseInstance.prepare(sql).get(value);
|
|
178
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Execute a query and return the result as an array of rows.
|
|
181
|
+
* @param sqlQuery The SQL query to execute.
|
|
182
|
+
* @param params The parameters for the query.
|
|
183
|
+
* @returns The result as an array of rows.
|
|
184
|
+
*/
|
|
179
185
|
query(sqlQuery = '', params = []) {
|
|
180
186
|
return this.databaseInstance.prepare(sqlQuery).all(...params);
|
|
181
187
|
}
|
|
@@ -199,6 +205,13 @@ export class SQLiteTableInstance {
|
|
|
199
205
|
},
|
|
200
206
|
});
|
|
201
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Update one or more rows in the table.
|
|
210
|
+
* @param whereClause The WHERE clause to filter the rows to update.
|
|
211
|
+
* @param newData The data to update the rows with.
|
|
212
|
+
* @param params The parameters for the WHERE clause.
|
|
213
|
+
* @returns The updated rows.
|
|
214
|
+
*/
|
|
202
215
|
update(whereClause = '', newData, params = []) {
|
|
203
216
|
const sql = `UPDATE ${this.tableName} SET ${Object.keys(newData).map(key => `${key} = ?`).join(', ')} WHERE ${whereClause}`;
|
|
204
217
|
return this.databaseInstance.prepare(sql).all(...params);
|