rado 0.1.38 → 0.1.40
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/driver/sql.js.js
CHANGED
|
@@ -7,12 +7,13 @@ var PreparedStatement = class {
|
|
|
7
7
|
this.db = db;
|
|
8
8
|
this.stmt = stmt;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
*iterate(params) {
|
|
11
11
|
this.stmt.bind(params);
|
|
12
|
-
const res = [];
|
|
13
12
|
while (this.stmt.step())
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
yield this.stmt.getAsObject();
|
|
14
|
+
}
|
|
15
|
+
all(params) {
|
|
16
|
+
return Array.from(this.iterate(params));
|
|
16
17
|
}
|
|
17
18
|
run(params) {
|
|
18
19
|
this.stmt.run(params);
|
package/dist/driver/sqlite3.js
CHANGED
|
@@ -6,6 +6,37 @@ var PreparedStatement = class {
|
|
|
6
6
|
constructor(stmt) {
|
|
7
7
|
this.stmt = stmt;
|
|
8
8
|
}
|
|
9
|
+
async *iterate(params) {
|
|
10
|
+
let rows = [], done = false, error;
|
|
11
|
+
let resolve;
|
|
12
|
+
let promise = new Promise((r) => resolve = r);
|
|
13
|
+
this.stmt.each(
|
|
14
|
+
params,
|
|
15
|
+
(err, row) => {
|
|
16
|
+
if (err)
|
|
17
|
+
error = err;
|
|
18
|
+
else
|
|
19
|
+
rows.push(row);
|
|
20
|
+
resolve();
|
|
21
|
+
},
|
|
22
|
+
() => {
|
|
23
|
+
done = true;
|
|
24
|
+
resolve();
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
while (true) {
|
|
28
|
+
const mustWait = !(rows.length || error || done);
|
|
29
|
+
if (mustWait)
|
|
30
|
+
await promise;
|
|
31
|
+
promise = new Promise((r) => resolve = r);
|
|
32
|
+
if (error)
|
|
33
|
+
throw error;
|
|
34
|
+
if (rows.length)
|
|
35
|
+
yield rows.shift();
|
|
36
|
+
if (done)
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
9
40
|
all(params) {
|
|
10
41
|
return new Promise((resolve, reject) => {
|
|
11
42
|
this.stmt.all(params, (err, rows) => {
|
package/dist/lib/Driver.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ declare abstract class SyncDriver extends DriverBase {
|
|
|
41
41
|
get<T>(cursor: Cursor.SelectMultiple<T>): T | null;
|
|
42
42
|
get<T>(cursor: Cursor<T>): T;
|
|
43
43
|
get<T>(strings: TemplateStringsArray, ...params: Array<any>): T;
|
|
44
|
+
iterate<T>(cursor: Cursor.SelectMultiple<T>): Iterable<T>;
|
|
44
45
|
transaction<T>(run: (query: SyncDriver) => T): T;
|
|
45
46
|
toAsync(): SyncWrapper;
|
|
46
47
|
}
|
|
@@ -48,6 +49,7 @@ interface SyncPreparedStatement {
|
|
|
48
49
|
run(params?: Array<any>): {
|
|
49
50
|
rowsAffected: number;
|
|
50
51
|
};
|
|
52
|
+
iterate<T>(params?: Array<any>): Iterable<T>;
|
|
51
53
|
all<T>(params?: Array<any>): Array<T>;
|
|
52
54
|
get<T>(params?: Array<any>): T;
|
|
53
55
|
execute(params?: Array<any>): void;
|
|
@@ -71,6 +73,7 @@ declare abstract class AsyncDriver extends DriverBase {
|
|
|
71
73
|
get<T>(cursor: Cursor.SelectMultiple<T>): Promise<T | null>;
|
|
72
74
|
get<T>(cursor: Cursor<T>): Promise<T>;
|
|
73
75
|
get<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<T>;
|
|
76
|
+
iterate<T>(cursor: Cursor.SelectMultiple<T>): AsyncIterable<T>;
|
|
74
77
|
transaction<T>(run: (query: AsyncDriver) => T): Promise<T>;
|
|
75
78
|
}
|
|
76
79
|
declare class SyncWrapper extends AsyncDriver {
|
|
@@ -86,6 +89,7 @@ interface AsyncPreparedStatement {
|
|
|
86
89
|
run(params?: Array<any>): Promise<{
|
|
87
90
|
rowsAffected: number;
|
|
88
91
|
}>;
|
|
92
|
+
iterate<T>(params?: Array<any>): AsyncIterable<T>;
|
|
89
93
|
all<T>(params?: Array<any>): Promise<Array<T>>;
|
|
90
94
|
get<T>(params?: Array<any>): Promise<T>;
|
|
91
95
|
execute(params?: Array<any>): Promise<void>;
|
package/dist/lib/Driver.js
CHANGED
|
@@ -141,6 +141,12 @@ var SyncDriver = class extends DriverBase {
|
|
|
141
141
|
get(...args) {
|
|
142
142
|
return super.get(...args);
|
|
143
143
|
}
|
|
144
|
+
*iterate(cursor) {
|
|
145
|
+
const stmt = this.prepareStatement(this.formatter.compile(cursor.query()));
|
|
146
|
+
for (const row of stmt.iterate()) {
|
|
147
|
+
yield JSON.parse(row.result).result;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
144
150
|
transaction(run) {
|
|
145
151
|
const id = `t${this.transactionId++}`;
|
|
146
152
|
this.executeQuery(
|
|
@@ -240,6 +246,12 @@ var AsyncDriver = class extends DriverBase {
|
|
|
240
246
|
get(...args) {
|
|
241
247
|
return super.get(...args);
|
|
242
248
|
}
|
|
249
|
+
async *iterate(cursor) {
|
|
250
|
+
const stmt = this.prepareStatement(this.formatter.compile(cursor.query()));
|
|
251
|
+
for await (const row of stmt.iterate()) {
|
|
252
|
+
yield JSON.parse(row.result).result;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
243
255
|
async transaction(run) {
|
|
244
256
|
const id = `t${this.transactionId++}`;
|
|
245
257
|
const [connection, release] = this.isolate();
|
|
@@ -266,6 +278,10 @@ var SyncPreparedStatementWrapper = class {
|
|
|
266
278
|
constructor(stmt) {
|
|
267
279
|
this.stmt = stmt;
|
|
268
280
|
}
|
|
281
|
+
async *iterate(params) {
|
|
282
|
+
for (const row of this.stmt.iterate(params))
|
|
283
|
+
yield row;
|
|
284
|
+
}
|
|
269
285
|
async run(params) {
|
|
270
286
|
return this.stmt.run(params);
|
|
271
287
|
}
|
|
@@ -47,9 +47,9 @@ export type SqliteFunctions = {
|
|
|
47
47
|
/** The ltrim(X,Y) function returns a string formed by removing any and all characters that appear in Y from the left side of X. If the Y argument is omitted, ltrim(X) removes spaces from the left side of X.**/
|
|
48
48
|
ltrim(x: EV<string>, y?: EV<string>): Expr<string>;
|
|
49
49
|
/** The multi-argument max() function returns the argument with the maximum value, or return NULL if any argument is NULL. The multi-argument max() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to max() define a collating function, then the BINARY collating function is used. Note that max() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument.*/
|
|
50
|
-
max<T>(x: EV<T>,
|
|
50
|
+
max<T>(x: EV<T>, ...rest: Array<EV<T>>): Expr<T>;
|
|
51
51
|
/** The multi-argument min() function returns the argument with the minimum value. The multi-argument min() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to min() define a collating function, then the BINARY collating function is used. Note that min() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument.*/
|
|
52
|
-
min<T>(x: EV<T>,
|
|
52
|
+
min<T>(x: EV<T>, ...rest: Array<EV<T>>): Expr<T>;
|
|
53
53
|
/** The nullif(X,Y) function returns its first argument if the arguments are different and NULL if the arguments are the same. The nullif(X,Y) function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If neither argument to nullif() defines a collating function then the BINARY is used.*/
|
|
54
54
|
nullif<T>(x: EV<T>, y: EV<T>): Expr<T | null>;
|
|
55
55
|
/** The prnumberf(FORMAT,...) SQL function works like the sqlite3_mprnumberf() C-language function and the prnumberf() function from the standard C library. The first argument is a format string that specifies how to construct the output string using values taken from subsequent arguments. If the FORMAT argument is missing or NULL then the result is NULL. The %n format is silently ignored and does not consume an argument. The %p format is an alias for %X. The %z format is numbererchangeable with %s. If there are too few arguments in the argument list, missing arguments are assumed to have a NULL value, which is translated numbero 0 or 0.0 for numeric formats or an empty string for %s. See the built-in prnumberf() documentation for additional information.*/
|
|
@@ -162,4 +162,4 @@ export declare const count: (x?: Expr<any>) => Expr<number>, iif: <T>(x: EV<bool
|
|
|
162
162
|
(x: EV<any>, type: 'real'): Expr<number>;
|
|
163
163
|
(x: EV<any>, type: 'integer'): Expr<number>;
|
|
164
164
|
(x: EV<any>, type: 'numeric'): Expr<number>;
|
|
165
|
-
}, abs: (x: EV<number>) => Expr<number>, changes: () => Expr<number>, char: (...arg: Array<EV<number>>) => Expr<string>, coalesce: (x: EV<any>, y: EV<any>, ...rest: EV<any>) => Expr<any>, ifnull: <T>(x: EV<T>, y: EV<T>) => Expr<T>, instr: (x: EV<string>, y: EV<string>) => Expr<number>, last_insert_rowid: () => Expr<number>, length: (x: EV<string>) => Expr<number>, likelihood: (x: EV<boolean>, y: number) => Expr<boolean>, likely: (x: EV<boolean>) => Expr<boolean>, lower: (x: EV<string>) => Expr<string>, ltrim: (x: EV<string>, y?: EV<string>) => Expr<string>, max: <T>(x: EV<T>,
|
|
165
|
+
}, abs: (x: EV<number>) => Expr<number>, changes: () => Expr<number>, char: (...arg: Array<EV<number>>) => Expr<string>, coalesce: (x: EV<any>, y: EV<any>, ...rest: EV<any>) => Expr<any>, ifnull: <T>(x: EV<T>, y: EV<T>) => Expr<T>, instr: (x: EV<string>, y: EV<string>) => Expr<number>, last_insert_rowid: () => Expr<number>, length: (x: EV<string>) => Expr<number>, likelihood: (x: EV<boolean>, y: number) => Expr<boolean>, likely: (x: EV<boolean>) => Expr<boolean>, lower: (x: EV<string>) => Expr<string>, ltrim: (x: EV<string>, y?: EV<string>) => Expr<string>, max: <T>(x: EV<T>, ...rest: EV<T>[]) => Expr<T>, min: <T>(x: EV<T>, ...rest: EV<T>[]) => Expr<T>, nullif: <T>(x: EV<T>, y: EV<T>) => Expr<T | null>, prnumberf: (format: string, ...rest: Array<Expr<any>>) => Expr<string>, quote: (x: EV<string>) => Expr<string>, random: () => Expr<number>, replace: (x: EV<string>, y: EV<string>, z: EV<string>) => Expr<string>, round: (x: EV<number>, y?: EV<number>) => Expr<number>, rtrim: (x: EV<string>, y?: EV<string>) => Expr<string>, sign: (x: EV<number>) => Expr<number>, soundex: (x: EV<string>) => Expr<string>, sqlite_version: () => Expr<string>, substr: (x: EV<string>, y: EV<number>, z?: EV<number>) => Expr<string>, total_changes: () => Expr<number>, trim: (x: EV<string>, Y: EV<string>) => Expr<string>, unicode: (x: EV<string>) => Expr<number>, unlikely: (x: EV<boolean>) => Expr<boolean>, upper: (x: EV<string>) => Expr<string>, avg: (x: Expr<number>) => Expr<number>, group_concat: (x: EV<string>, y: EV<string>) => Expr<string>, sum: (x: EV<number>) => Expr<number>, acos: (x: EV<number>) => Expr<number>, acosh: (x: EV<number>) => Expr<number>, asin: (x: EV<number>) => Expr<number>, asinh: (x: EV<number>) => Expr<number>, atan: (x: EV<number>) => Expr<number>, atan2: (x: EV<number>, y: EV<number>) => Expr<number>, atanh: (x: EV<number>) => Expr<number>, ceil: (x: EV<number>) => Expr<number>, cos: (x: EV<number>) => Expr<number>, cosh: (x: EV<number>) => Expr<number>, degrees: (x: EV<number>) => Expr<number>, exp: (x: EV<number>) => Expr<number>, floor: (x: EV<number>) => Expr<number>, ln: (x: EV<number>) => Expr<number>, log: (x: EV<number>, y?: EV<number>) => Expr<number>, log2: (x: EV<number>) => Expr<number>, mod: (x: EV<number>, y: EV<number>) => Expr<number>, pi: (x: EV<number>) => Expr<number>, pow: (x: EV<number>, y: EV<number>) => Expr<number>, radians: (x: EV<number>) => Expr<number>, sin: (x: EV<number>) => Expr<number>, sinh: (x: EV<number>) => Expr<number>, sqrt: (x: EV<number>) => Expr<number>, tan: (x: EV<number>) => Expr<number>, tanh: (x: EV<number>) => Expr<number>, trunc: (x: EV<number>) => Expr<number>, date: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, time: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, datetime: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, julianday: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, strftime: (format: EV<string>, timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>;
|