rado 0.1.0 → 0.1.1
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.d.ts +58 -55
- package/dist/Driver.js +185 -187
- package/dist/driver/better-sqlite3.js +7 -11
- package/dist/driver/sql.js.js +7 -11
- package/dist/driver/sqlite3.js +7 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/sqlite/SqliteSchema.d.ts +1 -1
- package/dist/sqlite/SqliteSchema.js +2 -0
- package/package.json +1 -1
package/dist/Driver.d.ts
CHANGED
|
@@ -15,61 +15,64 @@ declare abstract class DriverBase extends Callable {
|
|
|
15
15
|
executeTemplate(expectedReturn: Query.RawReturn, strings: TemplateStringsArray, ...params: Array<any>): any;
|
|
16
16
|
abstract executeQuery(query: Query<any>): any;
|
|
17
17
|
}
|
|
18
|
+
interface SyncDriver {
|
|
19
|
+
<T>(query: Cursor<T>): T;
|
|
20
|
+
(strings: TemplateStringsArray, ...values: any[]): any;
|
|
21
|
+
}
|
|
22
|
+
declare abstract class SyncDriver extends DriverBase {
|
|
23
|
+
transactionId: number;
|
|
24
|
+
abstract rows(stmt: Statement.Compiled): Array<object>;
|
|
25
|
+
abstract values(stmt: Statement.Compiled): Array<Array<any>>;
|
|
26
|
+
abstract execute(stmt: Statement.Compiled): void;
|
|
27
|
+
abstract mutate(stmt: Statement.Compiled): {
|
|
28
|
+
rowsAffected: number;
|
|
29
|
+
};
|
|
30
|
+
abstract schemaInstructions(tableName: string): SchemaInstructions | undefined;
|
|
31
|
+
migrateSchema(...tables: Array<Table<any>>): unknown;
|
|
32
|
+
executeQuery<T>(query: Query<T>): T;
|
|
33
|
+
all<T>(strings: TemplateStringsArray, ...params: Array<any>): Array<T>;
|
|
34
|
+
get<T>(strings: TemplateStringsArray, ...params: Array<any>): T;
|
|
35
|
+
transaction<T>(run: (query: SyncDriver) => T): T;
|
|
36
|
+
toAsync(): SyncWrapper;
|
|
37
|
+
}
|
|
38
|
+
interface AsyncDriver {
|
|
39
|
+
<T>(query: Cursor<T>): Promise<T>;
|
|
40
|
+
(strings: TemplateStringsArray, ...values: any[]): Promise<any>;
|
|
41
|
+
}
|
|
42
|
+
declare abstract class AsyncDriver extends DriverBase {
|
|
43
|
+
transactionId: number;
|
|
44
|
+
abstract isolate(): [connection: AsyncDriver, release: () => Promise<void>];
|
|
45
|
+
abstract rows(stmt: Statement.Compiled): Promise<Array<object>>;
|
|
46
|
+
abstract values(stmt: Statement.Compiled): Promise<Array<Array<any>>>;
|
|
47
|
+
abstract execute(stmt: Statement.Compiled): Promise<void>;
|
|
48
|
+
abstract mutate(stmt: Statement.Compiled): Promise<{
|
|
49
|
+
rowsAffected: number;
|
|
50
|
+
}>;
|
|
51
|
+
abstract schemaInstructions(tableName: string): Promise<SchemaInstructions | undefined>;
|
|
52
|
+
migrateSchema(...tables: Array<Table<any>>): Promise<unknown>;
|
|
53
|
+
executeQuery<T>(query: Query<T>): Promise<T>;
|
|
54
|
+
all<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<Array<T>>;
|
|
55
|
+
get<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<T>;
|
|
56
|
+
transaction<T>(run: (query: AsyncDriver) => T): Promise<T>;
|
|
57
|
+
}
|
|
58
|
+
declare class SyncWrapper extends AsyncDriver {
|
|
59
|
+
private sync;
|
|
60
|
+
lock: Promise<void> | undefined;
|
|
61
|
+
constructor(sync: SyncDriver);
|
|
62
|
+
executeQuery<T>(query: Query<T>): Promise<T>;
|
|
63
|
+
rows(stmt: Statement.Compiled): Promise<Array<object>>;
|
|
64
|
+
values(stmt: Statement.Compiled): Promise<Array<Array<any>>>;
|
|
65
|
+
execute(stmt: Statement.Compiled): Promise<void>;
|
|
66
|
+
mutate(stmt: Statement.Compiled): Promise<{
|
|
67
|
+
rowsAffected: number;
|
|
68
|
+
}>;
|
|
69
|
+
schemaInstructions(tableName: string): Promise<SchemaInstructions | undefined>;
|
|
70
|
+
isolate(): [connection: AsyncDriver, release: () => Promise<void>];
|
|
71
|
+
}
|
|
18
72
|
export declare namespace Driver {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export abstract class Sync extends DriverBase {
|
|
24
|
-
transactionId: number;
|
|
25
|
-
abstract rows(stmt: Statement.Compiled): Array<object>;
|
|
26
|
-
abstract values(stmt: Statement.Compiled): Array<Array<any>>;
|
|
27
|
-
abstract execute(stmt: Statement.Compiled): void;
|
|
28
|
-
abstract mutate(stmt: Statement.Compiled): {
|
|
29
|
-
rowsAffected: number;
|
|
30
|
-
};
|
|
31
|
-
abstract schemaInstructions(tableName: string): SchemaInstructions | undefined;
|
|
32
|
-
migrateSchema(...tables: Array<Table<any>>): unknown;
|
|
33
|
-
executeQuery<T>(query: Query<T>): T;
|
|
34
|
-
all<T>(strings: TemplateStringsArray, ...params: Array<any>): Array<T>;
|
|
35
|
-
get<T>(strings: TemplateStringsArray, ...params: Array<any>): T;
|
|
36
|
-
transaction<T>(run: (query: Sync) => T): T;
|
|
37
|
-
toAsync(): SyncWrapper;
|
|
38
|
-
}
|
|
39
|
-
export interface Async {
|
|
40
|
-
<T>(query: Cursor<T>): Promise<T>;
|
|
41
|
-
(strings: TemplateStringsArray, ...values: any[]): Promise<any>;
|
|
42
|
-
}
|
|
43
|
-
export abstract class Async extends DriverBase {
|
|
44
|
-
transactionId: number;
|
|
45
|
-
abstract isolate(): [connection: Async, release: () => Promise<void>];
|
|
46
|
-
abstract rows(stmt: Statement.Compiled): Promise<Array<object>>;
|
|
47
|
-
abstract values(stmt: Statement.Compiled): Promise<Array<Array<any>>>;
|
|
48
|
-
abstract execute(stmt: Statement.Compiled): Promise<void>;
|
|
49
|
-
abstract mutate(stmt: Statement.Compiled): Promise<{
|
|
50
|
-
rowsAffected: number;
|
|
51
|
-
}>;
|
|
52
|
-
abstract schemaInstructions(tableName: string): Promise<SchemaInstructions | undefined>;
|
|
53
|
-
migrateSchema(...tables: Array<Table<any>>): Promise<unknown>;
|
|
54
|
-
executeQuery<T>(query: Query<T>): Promise<T>;
|
|
55
|
-
all<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<Array<T>>;
|
|
56
|
-
get<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<T>;
|
|
57
|
-
transaction<T>(run: (query: Async) => T): Promise<T>;
|
|
58
|
-
}
|
|
59
|
-
class SyncWrapper extends Async {
|
|
60
|
-
private sync;
|
|
61
|
-
lock: Promise<void> | undefined;
|
|
62
|
-
constructor(sync: Sync);
|
|
63
|
-
executeQuery<T>(query: Query<T>): Promise<T>;
|
|
64
|
-
rows(stmt: Statement.Compiled): Promise<Array<object>>;
|
|
65
|
-
values(stmt: Statement.Compiled): Promise<Array<Array<any>>>;
|
|
66
|
-
execute(stmt: Statement.Compiled): Promise<void>;
|
|
67
|
-
mutate(stmt: Statement.Compiled): Promise<{
|
|
68
|
-
rowsAffected: number;
|
|
69
|
-
}>;
|
|
70
|
-
schemaInstructions(tableName: string): Promise<SchemaInstructions | undefined>;
|
|
71
|
-
isolate(): [connection: Async, release: () => Promise<void>];
|
|
72
|
-
}
|
|
73
|
-
export {};
|
|
73
|
+
type Sync = SyncDriver;
|
|
74
|
+
const Sync: typeof SyncDriver;
|
|
75
|
+
type Async = AsyncDriver;
|
|
76
|
+
const Async: typeof AsyncDriver;
|
|
74
77
|
}
|
|
75
78
|
export {};
|
package/dist/Driver.js
CHANGED
|
@@ -34,210 +34,208 @@ var DriverBase = class extends Callable {
|
|
|
34
34
|
return this.executeQuery(Query.Raw({ strings, params, expectedReturn }));
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (changes.length)
|
|
51
|
-
queries.push(...changes);
|
|
52
|
-
}
|
|
37
|
+
var SyncDriver = class extends DriverBase {
|
|
38
|
+
transactionId = 0;
|
|
39
|
+
migrateSchema(...tables) {
|
|
40
|
+
const queries = [];
|
|
41
|
+
for (const table of Object.values(tables)) {
|
|
42
|
+
const schema = table.schema();
|
|
43
|
+
const localSchema = this.schemaInstructions(schema.name);
|
|
44
|
+
if (!localSchema) {
|
|
45
|
+
queries.push(...Schema.create(schema).queries);
|
|
46
|
+
} else {
|
|
47
|
+
const changes = Schema.upgrade(this.formatter, localSchema, schema);
|
|
48
|
+
if (changes.length)
|
|
49
|
+
queries.push(...changes);
|
|
53
50
|
}
|
|
54
|
-
return this.executeQuery(Query.Batch({ queries }));
|
|
55
51
|
}
|
|
56
|
-
executeQuery(
|
|
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
|
-
} else {
|
|
90
|
-
return this.mutate(stmt);
|
|
52
|
+
return this.executeQuery(Query.Batch({ queries }));
|
|
53
|
+
}
|
|
54
|
+
executeQuery(query) {
|
|
55
|
+
switch (query.type) {
|
|
56
|
+
case QueryType.Batch:
|
|
57
|
+
let result;
|
|
58
|
+
const stmts = query.queries;
|
|
59
|
+
if (stmts.length === 0)
|
|
60
|
+
return void 0;
|
|
61
|
+
if (stmts.length === 1)
|
|
62
|
+
return this.executeQuery(stmts[0]);
|
|
63
|
+
return this.transaction((cnx) => {
|
|
64
|
+
for (const query2 of stmts)
|
|
65
|
+
result = cnx.executeQuery(query2);
|
|
66
|
+
return result;
|
|
67
|
+
});
|
|
68
|
+
default:
|
|
69
|
+
const stmt = this.formatter.compile(query);
|
|
70
|
+
if ("selection" in query) {
|
|
71
|
+
const res = this.values(stmt).map(([item]) => JSON.parse(item).result);
|
|
72
|
+
if (query.singleResult)
|
|
73
|
+
return res[0];
|
|
74
|
+
return res;
|
|
75
|
+
} else if (query.type === QueryType.Raw) {
|
|
76
|
+
switch (query.expectedReturn) {
|
|
77
|
+
case "row":
|
|
78
|
+
return this.rows(stmt)[0];
|
|
79
|
+
case "rows":
|
|
80
|
+
return this.rows(stmt);
|
|
81
|
+
default:
|
|
82
|
+
this.execute(stmt);
|
|
83
|
+
return void 0;
|
|
91
84
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return super.all(strings, ...params);
|
|
96
|
-
}
|
|
97
|
-
get(strings, ...params) {
|
|
98
|
-
return super.get(strings, ...params);
|
|
85
|
+
} else {
|
|
86
|
+
return this.mutate(stmt);
|
|
87
|
+
}
|
|
99
88
|
}
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
}
|
|
90
|
+
all(strings, ...params) {
|
|
91
|
+
return super.all(strings, ...params);
|
|
92
|
+
}
|
|
93
|
+
get(strings, ...params) {
|
|
94
|
+
return super.get(strings, ...params);
|
|
95
|
+
}
|
|
96
|
+
transaction(run) {
|
|
97
|
+
const id = `t${this.transactionId++}`;
|
|
98
|
+
this.executeQuery(
|
|
99
|
+
Query.Transaction({ op: Query.TransactionOperation.Begin, id })
|
|
100
|
+
);
|
|
101
|
+
try {
|
|
102
|
+
const res = run(this);
|
|
102
103
|
this.executeQuery(
|
|
103
|
-
Query.Transaction({ op: Query.TransactionOperation.
|
|
104
|
+
Query.Transaction({ op: Query.TransactionOperation.Commit, id })
|
|
104
105
|
);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
} catch (e) {
|
|
112
|
-
this.executeQuery(
|
|
113
|
-
Query.Transaction({ op: Query.TransactionOperation.Rollback, id })
|
|
114
|
-
);
|
|
115
|
-
throw e;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
toAsync() {
|
|
119
|
-
return new SyncWrapper(this);
|
|
106
|
+
return res;
|
|
107
|
+
} catch (e) {
|
|
108
|
+
this.executeQuery(
|
|
109
|
+
Query.Transaction({ op: Query.TransactionOperation.Rollback, id })
|
|
110
|
+
);
|
|
111
|
+
throw e;
|
|
120
112
|
}
|
|
121
113
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
114
|
+
toAsync() {
|
|
115
|
+
return new SyncWrapper(this);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
var AsyncDriver = class extends DriverBase {
|
|
119
|
+
transactionId = 0;
|
|
120
|
+
async migrateSchema(...tables) {
|
|
121
|
+
const queries = [];
|
|
122
|
+
for (const table of Object.values(tables)) {
|
|
123
|
+
const schema = table.schema();
|
|
124
|
+
const localSchema = await this.schemaInstructions(schema.name);
|
|
125
|
+
if (!localSchema) {
|
|
126
|
+
queries.push(...Schema.create(schema).queries);
|
|
127
|
+
} else {
|
|
128
|
+
const changes = Schema.upgrade(this.formatter, localSchema, schema);
|
|
129
|
+
if (changes.length)
|
|
130
|
+
queries.push(...changes);
|
|
137
131
|
}
|
|
138
|
-
return this.executeQuery(Query.Batch({ queries }));
|
|
139
132
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return await this.mutate(stmt);
|
|
133
|
+
return this.executeQuery(Query.Batch({ queries }));
|
|
134
|
+
}
|
|
135
|
+
async executeQuery(query) {
|
|
136
|
+
switch (query.type) {
|
|
137
|
+
case QueryType.Batch:
|
|
138
|
+
let result;
|
|
139
|
+
const stmts = query.queries;
|
|
140
|
+
if (stmts.length === 0)
|
|
141
|
+
return void 0;
|
|
142
|
+
if (stmts.length === 1)
|
|
143
|
+
return this.executeQuery(stmts[0]);
|
|
144
|
+
return this.transaction(async (cnx) => {
|
|
145
|
+
for (const query2 of stmts)
|
|
146
|
+
result = await cnx.executeQuery(query2);
|
|
147
|
+
return result;
|
|
148
|
+
});
|
|
149
|
+
default:
|
|
150
|
+
const stmt = this.formatter.compile(query);
|
|
151
|
+
if ("selection" in query) {
|
|
152
|
+
const res = (await this.values(stmt)).map(
|
|
153
|
+
([item]) => JSON.parse(item).result
|
|
154
|
+
);
|
|
155
|
+
if (query.singleResult)
|
|
156
|
+
return res[0];
|
|
157
|
+
return res;
|
|
158
|
+
} else if (query.type === QueryType.Raw) {
|
|
159
|
+
switch (query.expectedReturn) {
|
|
160
|
+
case "row":
|
|
161
|
+
return (await this.rows(stmt))[0];
|
|
162
|
+
case "rows":
|
|
163
|
+
return await this.rows(stmt);
|
|
164
|
+
default:
|
|
165
|
+
await this.execute(stmt);
|
|
166
|
+
return void 0;
|
|
175
167
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return super.all(strings, ...params);
|
|
180
|
-
}
|
|
181
|
-
get(strings, ...params) {
|
|
182
|
-
return super.get(strings, ...params);
|
|
168
|
+
} else {
|
|
169
|
+
return await this.mutate(stmt);
|
|
170
|
+
}
|
|
183
171
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
172
|
+
}
|
|
173
|
+
all(strings, ...params) {
|
|
174
|
+
return super.all(strings, ...params);
|
|
175
|
+
}
|
|
176
|
+
get(strings, ...params) {
|
|
177
|
+
return super.get(strings, ...params);
|
|
178
|
+
}
|
|
179
|
+
async transaction(run) {
|
|
180
|
+
const id = `t${this.transactionId++}`;
|
|
181
|
+
const [connection, release] = this.isolate();
|
|
182
|
+
await connection.executeQuery(
|
|
183
|
+
Query.Transaction({ op: Query.TransactionOperation.Begin, id })
|
|
184
|
+
);
|
|
185
|
+
try {
|
|
186
|
+
const res = await run(connection);
|
|
187
187
|
await connection.executeQuery(
|
|
188
|
-
Query.Transaction({ op: Query.TransactionOperation.
|
|
188
|
+
Query.Transaction({ op: Query.TransactionOperation.Commit, id })
|
|
189
189
|
);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
Query.Transaction({ op: Query.TransactionOperation.Rollback, id })
|
|
199
|
-
);
|
|
200
|
-
throw e;
|
|
201
|
-
} finally {
|
|
202
|
-
await release();
|
|
203
|
-
}
|
|
190
|
+
return res;
|
|
191
|
+
} catch (e) {
|
|
192
|
+
await connection.executeQuery(
|
|
193
|
+
Query.Transaction({ op: Query.TransactionOperation.Rollback, id })
|
|
194
|
+
);
|
|
195
|
+
throw e;
|
|
196
|
+
} finally {
|
|
197
|
+
await release();
|
|
204
198
|
}
|
|
205
199
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
async mutate(stmt) {
|
|
227
|
-
return this.sync.mutate(stmt);
|
|
228
|
-
}
|
|
229
|
-
async schemaInstructions(tableName) {
|
|
230
|
-
return this.sync.schemaInstructions(tableName);
|
|
231
|
-
}
|
|
232
|
-
isolate() {
|
|
233
|
-
const connection = new SyncWrapper(this.sync);
|
|
234
|
-
let release, trigger = new Promise((resolve) => {
|
|
235
|
-
release = async () => resolve();
|
|
236
|
-
});
|
|
237
|
-
this.lock = Promise.resolve(this.lock).then(() => trigger);
|
|
238
|
-
return [connection, release];
|
|
239
|
-
}
|
|
200
|
+
};
|
|
201
|
+
var SyncWrapper = class extends AsyncDriver {
|
|
202
|
+
constructor(sync) {
|
|
203
|
+
super(sync.formatter);
|
|
204
|
+
this.sync = sync;
|
|
205
|
+
}
|
|
206
|
+
lock;
|
|
207
|
+
async executeQuery(query) {
|
|
208
|
+
await this.lock;
|
|
209
|
+
return super.executeQuery(query);
|
|
210
|
+
}
|
|
211
|
+
async rows(stmt) {
|
|
212
|
+
return this.sync.rows(stmt);
|
|
213
|
+
}
|
|
214
|
+
async values(stmt) {
|
|
215
|
+
return this.sync.values(stmt);
|
|
216
|
+
}
|
|
217
|
+
async execute(stmt) {
|
|
218
|
+
return this.sync.execute(stmt);
|
|
240
219
|
}
|
|
220
|
+
async mutate(stmt) {
|
|
221
|
+
return this.sync.mutate(stmt);
|
|
222
|
+
}
|
|
223
|
+
async schemaInstructions(tableName) {
|
|
224
|
+
return this.sync.schemaInstructions(tableName);
|
|
225
|
+
}
|
|
226
|
+
isolate() {
|
|
227
|
+
const connection = new SyncWrapper(this.sync);
|
|
228
|
+
let release, trigger = new Promise((resolve) => {
|
|
229
|
+
release = async () => resolve();
|
|
230
|
+
});
|
|
231
|
+
this.lock = Promise.resolve(this.lock).then(() => trigger);
|
|
232
|
+
return [connection, release];
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
var Driver;
|
|
236
|
+
((Driver2) => {
|
|
237
|
+
Driver2.Sync = SyncDriver;
|
|
238
|
+
Driver2.Async = AsyncDriver;
|
|
241
239
|
})(Driver || (Driver = {}));
|
|
242
240
|
export {
|
|
243
241
|
Driver
|
|
@@ -21,17 +21,13 @@ var BetterSqlite3Driver = class extends Driver.Sync {
|
|
|
21
21
|
return { rowsAffected: changes };
|
|
22
22
|
}
|
|
23
23
|
schemaInstructions(tableName) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return SqliteSchema.createInstructions(columnData, indexData);
|
|
32
|
-
} catch (e) {
|
|
33
|
-
return void 0;
|
|
34
|
-
}
|
|
24
|
+
const columnData = this.rows(
|
|
25
|
+
SqliteSchema.tableData(tableName).compile(this.formatter)
|
|
26
|
+
);
|
|
27
|
+
const indexData = this.rows(
|
|
28
|
+
SqliteSchema.indexData(tableName).compile(this.formatter)
|
|
29
|
+
);
|
|
30
|
+
return SqliteSchema.createInstructions(columnData, indexData);
|
|
35
31
|
}
|
|
36
32
|
export() {
|
|
37
33
|
return this.db.serialize();
|
package/dist/driver/sql.js.js
CHANGED
|
@@ -31,17 +31,13 @@ var SqlJsDriver = class extends Driver.Sync {
|
|
|
31
31
|
return { rowsAffected: this.db.getRowsModified() };
|
|
32
32
|
}
|
|
33
33
|
schemaInstructions(tableName) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return SqliteSchema.createInstructions(columnData, indexData);
|
|
42
|
-
} catch (e) {
|
|
43
|
-
return void 0;
|
|
44
|
-
}
|
|
34
|
+
const columnData = this.rows(
|
|
35
|
+
SqliteSchema.tableData(tableName).compile(this.formatter)
|
|
36
|
+
);
|
|
37
|
+
const indexData = this.rows(
|
|
38
|
+
SqliteSchema.indexData(tableName).compile(this.formatter)
|
|
39
|
+
);
|
|
40
|
+
return SqliteSchema.createInstructions(columnData, indexData);
|
|
45
41
|
}
|
|
46
42
|
export() {
|
|
47
43
|
return this.db.export();
|
package/dist/driver/sqlite3.js
CHANGED
|
@@ -50,17 +50,13 @@ var Sqlite3Driver = class extends Driver.Async {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
async schemaInstructions(tableName) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return SqliteSchema.createInstructions(columnData, indexData);
|
|
61
|
-
} catch (e) {
|
|
62
|
-
return void 0;
|
|
63
|
-
}
|
|
53
|
+
const columnData = await this.rows(
|
|
54
|
+
SqliteSchema.tableData(tableName).compile(this.formatter)
|
|
55
|
+
);
|
|
56
|
+
const indexData = await this.rows(
|
|
57
|
+
SqliteSchema.indexData(tableName).compile(this.formatter)
|
|
58
|
+
);
|
|
59
|
+
return SqliteSchema.createInstructions(columnData, indexData);
|
|
64
60
|
}
|
|
65
61
|
isolate() {
|
|
66
62
|
const connection = new Sqlite3Driver(this.db);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './Column';
|
|
2
2
|
export * from './Cursor';
|
|
3
|
+
export * from './Driver';
|
|
3
4
|
export * from './Expr';
|
|
4
5
|
export * from './Fields';
|
|
5
6
|
export * from './Formatter';
|
|
@@ -9,6 +10,7 @@ export * from './OrderBy';
|
|
|
9
10
|
export * from './Param';
|
|
10
11
|
export * from './Query';
|
|
11
12
|
export * from './Sanitizer';
|
|
13
|
+
export * from './Schema';
|
|
12
14
|
export * from './Selection';
|
|
13
15
|
export * from './Statement';
|
|
14
16
|
export * from './Table';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
export * from "./Column.js";
|
|
3
3
|
export * from "./Cursor.js";
|
|
4
|
+
export * from "./Driver.js";
|
|
4
5
|
export * from "./Expr.js";
|
|
5
6
|
export * from "./Fields.js";
|
|
6
7
|
export * from "./Formatter.js";
|
|
@@ -10,6 +11,7 @@ export * from "./OrderBy.js";
|
|
|
10
11
|
export * from "./Param.js";
|
|
11
12
|
export * from "./Query.js";
|
|
12
13
|
export * from "./Sanitizer.js";
|
|
14
|
+
export * from "./Schema.js";
|
|
13
15
|
export * from "./Selection.js";
|
|
14
16
|
export * from "./Statement.js";
|
|
15
17
|
export * from "./Table.js";
|
|
@@ -18,7 +18,7 @@ export declare namespace SqliteSchema {
|
|
|
18
18
|
}
|
|
19
19
|
function tableData(tableName: string): Statement;
|
|
20
20
|
function indexData(tableName: string): Statement;
|
|
21
|
-
function createInstructions(columnData: Array<Column>, indexData: Array<Index>): SchemaInstructions;
|
|
21
|
+
function createInstructions(columnData: Array<Column>, indexData: Array<Index>): SchemaInstructions | undefined;
|
|
22
22
|
function columnInstruction(column: Column): [string, string];
|
|
23
23
|
function indexInstruction(index: Index): [string, string];
|
|
24
24
|
}
|
|
@@ -13,6 +13,8 @@ var SqliteSchema;
|
|
|
13
13
|
}
|
|
14
14
|
SqliteSchema2.indexData = indexData;
|
|
15
15
|
function createInstructions(columnData, indexData2) {
|
|
16
|
+
if (columnData.length === 0 && indexData2.length === 0)
|
|
17
|
+
return void 0;
|
|
16
18
|
const columns = columnData.map(columnInstruction);
|
|
17
19
|
const indexes = indexData2.map(indexInstruction);
|
|
18
20
|
return {
|