@tursodatabase/database-common 0.6.0-pre.25 → 0.6.0-pre.27
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/promise.d.ts +31 -0
- package/dist/promise.d.ts.map +1 -1
- package/dist/promise.js +60 -0
- package/package.json +1 -1
package/dist/promise.d.ts
CHANGED
|
@@ -31,6 +31,37 @@ declare class Database {
|
|
|
31
31
|
* @param {function} fn - The function to wrap in a transaction.
|
|
32
32
|
*/
|
|
33
33
|
transaction(fn: (...any: any[]) => Promise<any>): (...bindParameters: any[]) => Promise<any>;
|
|
34
|
+
/**
|
|
35
|
+
* Prepares the SQL and executes it as `Statement.run`, returning the run info.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} sql - The SQL statement string.
|
|
38
|
+
* @param {...any} bindParameters - Bind parameters, optionally followed by a query options object.
|
|
39
|
+
*/
|
|
40
|
+
run(sql: any, ...bindParameters: any[]): Promise<{
|
|
41
|
+
changes: number;
|
|
42
|
+
lastInsertRowid: number;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Prepares the SQL and executes it as `Statement.get`, returning the first row.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} sql - The SQL statement string.
|
|
48
|
+
* @param {...any} bindParameters - Bind parameters, optionally followed by a query options object.
|
|
49
|
+
*/
|
|
50
|
+
get(sql: any, ...bindParameters: any[]): Promise<any>;
|
|
51
|
+
/**
|
|
52
|
+
* Prepares the SQL and executes it as `Statement.all`, returning all rows.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} sql - The SQL statement string.
|
|
55
|
+
* @param {...any} bindParameters - Bind parameters, optionally followed by a query options object.
|
|
56
|
+
*/
|
|
57
|
+
all(sql: any, ...bindParameters: any[]): Promise<any[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Prepares the SQL and executes it as `Statement.iterate`, yielding each row.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} sql - The SQL statement string.
|
|
62
|
+
* @param {...any} bindParameters - Bind parameters, optionally followed by a query options object.
|
|
63
|
+
*/
|
|
64
|
+
iterate(sql: any, ...bindParameters: any[]): AsyncGenerator<any, void, unknown>;
|
|
34
65
|
pragma(source: any, options: any): Promise<any[]>;
|
|
35
66
|
backup(filename: any, options: any): void;
|
|
36
67
|
serialize(options: any): void;
|
package/dist/promise.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAA8C,MAAM,YAAY,CAAC;AAoDvH;;GAEG;AACH,cAAM,QAAQ;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IAEvB,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,cAAc,CAAkB;IACxC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAS;gBAEzB,EAAE,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IAa5D;;OAEG;IACG,OAAO;IAMb;;;;OAIG;IACH,OAAO,CAAC,GAAG,KAAA;IAqBX;;;;OAIG;IACH,WAAW,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,OAAA,KAAK,OAAO,CAAC,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,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AAG,CAAC,GAAG,cAAc,OAAA;IA+B3B;;;;OAIG;IACI,OAAO,CAAC,GAAG,cAAc,OAAA;IA4BhC;;;;OAIG;IACG,GAAG,CAAC,GAAG,cAAc,OAAA;IA+BrB,EAAE;IAIR;;OAEG;IACH,SAAS;IAKT;;;;;OAKG;IACH,IAAI,CAAC,GAAG,cAAc,OAAA;IAStB,KAAK;CAUN;AAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,CAAA"}
|
package/dist/promise.js
CHANGED
|
@@ -142,6 +142,66 @@ class Database {
|
|
|
142
142
|
Object.defineProperties(properties.exclusive.value, properties);
|
|
143
143
|
return properties.default.value;
|
|
144
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Prepares the SQL and executes it as `Statement.run`, returning the run info.
|
|
147
|
+
*
|
|
148
|
+
* @param {string} sql - The SQL statement string.
|
|
149
|
+
* @param {...any} bindParameters - Bind parameters, optionally followed by a query options object.
|
|
150
|
+
*/
|
|
151
|
+
async run(sql, ...bindParameters) {
|
|
152
|
+
const stmt = this.prepare(sql);
|
|
153
|
+
try {
|
|
154
|
+
return await stmt.run(...bindParameters);
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
await stmt.close();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Prepares the SQL and executes it as `Statement.get`, returning the first row.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} sql - The SQL statement string.
|
|
164
|
+
* @param {...any} bindParameters - Bind parameters, optionally followed by a query options object.
|
|
165
|
+
*/
|
|
166
|
+
async get(sql, ...bindParameters) {
|
|
167
|
+
const stmt = this.prepare(sql);
|
|
168
|
+
try {
|
|
169
|
+
return await stmt.get(...bindParameters);
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
await stmt.close();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Prepares the SQL and executes it as `Statement.all`, returning all rows.
|
|
177
|
+
*
|
|
178
|
+
* @param {string} sql - The SQL statement string.
|
|
179
|
+
* @param {...any} bindParameters - Bind parameters, optionally followed by a query options object.
|
|
180
|
+
*/
|
|
181
|
+
async all(sql, ...bindParameters) {
|
|
182
|
+
const stmt = this.prepare(sql);
|
|
183
|
+
try {
|
|
184
|
+
return await stmt.all(...bindParameters);
|
|
185
|
+
}
|
|
186
|
+
finally {
|
|
187
|
+
await stmt.close();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Prepares the SQL and executes it as `Statement.iterate`, yielding each row.
|
|
192
|
+
*
|
|
193
|
+
* @param {string} sql - The SQL statement string.
|
|
194
|
+
* @param {...any} bindParameters - Bind parameters, optionally followed by a query options object.
|
|
195
|
+
*/
|
|
196
|
+
async *iterate(sql, ...bindParameters) {
|
|
197
|
+
const stmt = this.prepare(sql);
|
|
198
|
+
try {
|
|
199
|
+
yield* stmt.iterate(...bindParameters);
|
|
200
|
+
}
|
|
201
|
+
finally {
|
|
202
|
+
await stmt.close();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
145
205
|
async pragma(source, options) {
|
|
146
206
|
if (options == null)
|
|
147
207
|
options = {};
|