rado 0.1.22 → 0.1.23

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.
Files changed (68) hide show
  1. package/README.md +1 -1
  2. package/dist/Column.d.ts +41 -0
  3. package/dist/Column.js +58 -0
  4. package/dist/Cursor.d.ts +77 -0
  5. package/dist/Cursor.js +211 -0
  6. package/dist/Driver.d.ts +72 -0
  7. package/dist/Driver.js +145 -0
  8. package/dist/Expr.d.ts +149 -0
  9. package/dist/Expr.js +284 -0
  10. package/dist/Fields.d.ts +9 -0
  11. package/dist/Fields.js +0 -0
  12. package/dist/Formatter.d.ts +50 -0
  13. package/dist/Formatter.js +453 -0
  14. package/dist/Functions.d.ts +8 -0
  15. package/dist/Functions.js +11 -0
  16. package/dist/Key.d.ts +5 -0
  17. package/dist/Ops.d.ts +8 -0
  18. package/dist/Ops.js +46 -0
  19. package/dist/OrderBy.d.ts +9 -0
  20. package/dist/OrderBy.js +9 -0
  21. package/dist/Param.d.ts +15 -0
  22. package/dist/Param.js +18 -0
  23. package/dist/Query.d.ts +94 -0
  24. package/dist/Query.js +57 -0
  25. package/dist/Sanitizer.d.ts +4 -0
  26. package/dist/Sanitizer.js +0 -0
  27. package/dist/Schema.d.ts +10 -0
  28. package/dist/Selection.d.ts +18 -0
  29. package/dist/Selection.js +0 -0
  30. package/dist/Statement.d.ts +57 -0
  31. package/dist/Statement.js +184 -0
  32. package/dist/Table.d.ts +47 -0
  33. package/dist/Table.js +82 -0
  34. package/dist/Target.d.ts +30 -0
  35. package/dist/Target.js +37 -0
  36. package/dist/Update.d.ts +4 -0
  37. package/dist/Update.js +0 -0
  38. package/dist/driver/better-sqlite3.d.ts +17 -17
  39. package/dist/driver/sql.js.d.ts +17 -17
  40. package/dist/driver/sqlite3.d.ts +20 -20
  41. package/dist/index.d.ts +20 -20
  42. package/dist/lib/Column.d.ts +57 -57
  43. package/dist/lib/Cursor.d.ts +77 -77
  44. package/dist/lib/Driver.d.ts +89 -89
  45. package/dist/lib/Expr.d.ts +154 -154
  46. package/dist/lib/Fields.d.ts +13 -13
  47. package/dist/lib/Formatter.d.ts +56 -56
  48. package/dist/lib/Functions.d.ts +7 -7
  49. package/dist/lib/Id.d.ts +3 -3
  50. package/dist/lib/Index.d.ts +17 -17
  51. package/dist/lib/Ops.d.ts +8 -8
  52. package/dist/lib/OrderBy.d.ts +9 -9
  53. package/dist/lib/Param.d.ts +15 -15
  54. package/dist/lib/Query.d.ts +108 -108
  55. package/dist/lib/Sanitizer.d.ts +4 -4
  56. package/dist/lib/Schema.d.ts +18 -18
  57. package/dist/lib/Selection.d.ts +20 -20
  58. package/dist/lib/Statement.d.ts +61 -61
  59. package/dist/lib/Table.d.ts +58 -58
  60. package/dist/lib/Target.d.ts +30 -30
  61. package/dist/lib/Update.d.ts +4 -4
  62. package/dist/sqlite/SqliteFormatter.d.ts +11 -11
  63. package/dist/sqlite/SqliteFunctions.d.ts +156 -156
  64. package/dist/sqlite/SqliteSchema.d.ts +24 -24
  65. package/dist/sqlite/index.d.ts +2 -0
  66. package/dist/sqlite/index.js +3 -0
  67. package/dist/sqlite.d.ts +2 -2
  68. package/package.json +47 -47
package/dist/Query.js ADDED
@@ -0,0 +1,57 @@
1
+ // src/Query.ts
2
+ var QueryType = /* @__PURE__ */ ((QueryType2) => {
3
+ QueryType2["Insert"] = "Insert";
4
+ QueryType2["Select"] = "Select";
5
+ QueryType2["Update"] = "Update";
6
+ QueryType2["Delete"] = "Delete";
7
+ QueryType2["CreateTable"] = "CreateTable";
8
+ QueryType2["Batch"] = "Batch";
9
+ QueryType2["Transaction"] = "Transaction";
10
+ QueryType2["Raw"] = "Raw";
11
+ return QueryType2;
12
+ })(QueryType || {});
13
+ var Query;
14
+ ((Query2) => {
15
+ function Insert(insert) {
16
+ return { type: "Insert" /* Insert */, ...insert };
17
+ }
18
+ Query2.Insert = Insert;
19
+ function Select(select) {
20
+ return { type: "Select" /* Select */, ...select };
21
+ }
22
+ Query2.Select = Select;
23
+ function Update(update) {
24
+ return { type: "Update" /* Update */, ...update };
25
+ }
26
+ Query2.Update = Update;
27
+ function Delete(del) {
28
+ return { type: "Delete" /* Delete */, ...del };
29
+ }
30
+ Query2.Delete = Delete;
31
+ function CreateTable(create) {
32
+ return { type: "CreateTable" /* CreateTable */, ...create };
33
+ }
34
+ Query2.CreateTable = CreateTable;
35
+ function Batch(batch) {
36
+ return { type: "Batch" /* Batch */, ...batch };
37
+ }
38
+ Query2.Batch = Batch;
39
+ let TransactionOperation;
40
+ ((TransactionOperation2) => {
41
+ TransactionOperation2["Begin"] = "Begin";
42
+ TransactionOperation2["Commit"] = "Commit";
43
+ TransactionOperation2["Rollback"] = "Rollback";
44
+ })(TransactionOperation = Query2.TransactionOperation || (Query2.TransactionOperation = {}));
45
+ function Transaction(transaction) {
46
+ return { type: "Transaction" /* Transaction */, ...transaction };
47
+ }
48
+ Query2.Transaction = Transaction;
49
+ function Raw(raw) {
50
+ return { type: "Raw" /* Raw */, ...raw };
51
+ }
52
+ Query2.Raw = Raw;
53
+ })(Query || (Query = {}));
54
+ export {
55
+ Query,
56
+ QueryType
57
+ };
@@ -0,0 +1,4 @@
1
+ export interface Sanitizer {
2
+ escapeValue(value: any): string;
3
+ escapeIdentifier(ident: string): string;
4
+ }
File without changes
@@ -0,0 +1,10 @@
1
+ import { ColumnData } from './Column';
2
+ import { Query } from './Query';
3
+ export interface Schema {
4
+ name: string;
5
+ alias?: string;
6
+ columns: Record<string, ColumnData>;
7
+ }
8
+ export declare namespace Schema {
9
+ function diff(a: Schema, b: Schema): Array<Query.AlterTable>;
10
+ }
@@ -0,0 +1,18 @@
1
+ import type { Cursor } from './Cursor';
2
+ import type { Expr } from './Expr';
3
+ type SelectionBase = Expr<any> | Cursor.SelectMultiple<any> | Cursor.SelectSingle<any>;
4
+ interface SelectionRecord extends Record<string, Selection> {
5
+ }
6
+ export type Selection = SelectionBase | SelectionRecord;
7
+ export declare namespace Selection {
8
+ type Infer<T> = T extends {
9
+ __tableType: infer K;
10
+ } ? K : T extends {
11
+ __cursortype: infer K;
12
+ } ? K : T extends Expr<infer K> ? K : T extends Record<string, Selection> ? {
13
+ [K in keyof T]: Infer<T[K]>;
14
+ } : T;
15
+ type With<A, B> = Expr<Combine<A, B>>;
16
+ type Combine<A, B> = Omit<A, keyof Infer<B>> & Infer<B>;
17
+ }
18
+ export {};
File without changes
@@ -0,0 +1,57 @@
1
+ import { Sanitizer } from './Sanitizer';
2
+ declare const enum TokenType {
3
+ Raw = "Raw",
4
+ Identifier = "Identifier",
5
+ Value = "Value",
6
+ Indent = "Indent",
7
+ Dedent = "Dedent"
8
+ }
9
+ declare class Token {
10
+ type: TokenType;
11
+ data: any;
12
+ constructor(type: TokenType, data: any);
13
+ static Raw(data: string): Token;
14
+ static Indent(): Token;
15
+ static Dedent(): Token;
16
+ static Identifier(data: string): Token;
17
+ static Value(data: any): Token;
18
+ }
19
+ export declare class Statement {
20
+ tokens: Array<Token>;
21
+ constructor(tokens: Array<Token>);
22
+ concat(...tokens: Array<Token | Statement>): Statement;
23
+ static create(from: string | Statement): Statement;
24
+ static tag(strings: ReadonlyArray<string>, ...params: Array<any>): Statement;
25
+ space(): Statement;
26
+ call(method: string, ...args: Array<Statement>): Statement;
27
+ addCall(method: string, ...args: Array<Statement>): Statement;
28
+ add(addition: undefined | string | Statement): Statement;
29
+ addLine(addition: undefined | string | Statement): Statement;
30
+ addIf(condition: any, addition: string | Statement | (() => string | Statement)): Statement;
31
+ indent(): Statement;
32
+ dedent(): Statement;
33
+ newline(): Statement;
34
+ identifier(name: string): Statement;
35
+ addIdentifier(name: string): Statement;
36
+ value(value: any): Statement;
37
+ addValue(value: any): Statement;
38
+ raw(query: string): Statement;
39
+ parenthesis(inner: string | Statement): Statement;
40
+ addParenthesis(stmnt: string | Statement): Statement;
41
+ separated(input: Array<Statement>, separator?: string): Statement;
42
+ addSeparated(input: Array<Statement>, separator?: string): Statement;
43
+ isEmpty(): boolean;
44
+ compile(sanitizer: Sanitizer, formatInline?: boolean): Statement.Compiled;
45
+ }
46
+ export declare namespace Statement {
47
+ type Compiled = [sql: string, params: Array<any>];
48
+ }
49
+ export declare function newline(): Statement;
50
+ export declare function raw(raw: string): Statement;
51
+ export declare function identifier(name: string): Statement;
52
+ export declare function value(value: any): Statement;
53
+ export declare function empty(): Statement;
54
+ export declare function parenthesis(stmnt: Statement): Statement;
55
+ export declare function call(method: string, ...args: Array<Statement>): Statement;
56
+ export declare function separated(input: Array<Statement>, separator?: string): Statement;
57
+ export {};
@@ -0,0 +1,184 @@
1
+ // src/Statement.ts
2
+ var Token = class {
3
+ constructor(type, data) {
4
+ this.type = type;
5
+ this.data = data;
6
+ }
7
+ static Raw(data) {
8
+ return new Token("Raw" /* Raw */, data);
9
+ }
10
+ static Indent() {
11
+ return new Token("Indent" /* Indent */, null);
12
+ }
13
+ static Dedent() {
14
+ return new Token("Dedent" /* Dedent */, null);
15
+ }
16
+ static Identifier(data) {
17
+ return new Token("Identifier" /* Identifier */, data);
18
+ }
19
+ static Value(data) {
20
+ return new Token("Value" /* Value */, data);
21
+ }
22
+ };
23
+ var SEPARATE = ",";
24
+ var WHITESPACE = " ";
25
+ var NEWLINE = "\n";
26
+ var Statement = class {
27
+ constructor(tokens) {
28
+ this.tokens = tokens;
29
+ }
30
+ concat(...tokens) {
31
+ return new Statement(
32
+ this.tokens.concat(
33
+ ...tokens.flatMap((t) => t instanceof Statement ? t.tokens : [t])
34
+ )
35
+ );
36
+ }
37
+ static create(from) {
38
+ return typeof from === "string" ? raw(from) : from;
39
+ }
40
+ static ofTemplate(strings, params) {
41
+ return new Statement(
42
+ strings.flatMap((s, i) => [Token.Raw(s), Token.Value(params[i])]).slice(0, -1)
43
+ );
44
+ }
45
+ space() {
46
+ return this.concat(Token.Raw(WHITESPACE));
47
+ }
48
+ call(method, ...args) {
49
+ return this.identifier(method).parenthesis(separated(args));
50
+ }
51
+ addCall(method, ...args) {
52
+ return this.space().call(method, ...args);
53
+ }
54
+ add(addition) {
55
+ if (!addition)
56
+ return this;
57
+ if (addition instanceof Statement && addition.isEmpty())
58
+ return this;
59
+ return this.space().concat(Statement.create(addition));
60
+ }
61
+ addLine(addition) {
62
+ if (!addition)
63
+ return this;
64
+ if (addition instanceof Statement && addition.isEmpty())
65
+ return this;
66
+ return this.newline().concat(Statement.create(addition));
67
+ }
68
+ addIf(condition, addition) {
69
+ if (!condition)
70
+ return this;
71
+ return this.add(typeof addition === "function" ? addition() : addition);
72
+ }
73
+ indent() {
74
+ return this.concat(Token.Indent());
75
+ }
76
+ dedent() {
77
+ return this.concat(Token.Dedent());
78
+ }
79
+ newline() {
80
+ return this.raw(NEWLINE);
81
+ }
82
+ identifier(name) {
83
+ return this.concat(Token.Identifier(name));
84
+ }
85
+ addIdentifier(name) {
86
+ return this.space().identifier(name);
87
+ }
88
+ value(value2) {
89
+ return this.concat(Token.Value(value2));
90
+ }
91
+ addValue(value2) {
92
+ return this.space().value(value2);
93
+ }
94
+ raw(query) {
95
+ if (!query)
96
+ return this;
97
+ return this.concat(Token.Raw(query));
98
+ }
99
+ parenthesis(inner) {
100
+ return this.raw("(").indent().newline().concat(Statement.create(inner)).dedent().newline().raw(")");
101
+ }
102
+ addParenthesis(stmnt) {
103
+ return this.space().parenthesis(stmnt);
104
+ }
105
+ separated(input, separator = SEPARATE) {
106
+ return this.concat(
107
+ ...input.flatMap(
108
+ (stmt, i) => i === 0 ? stmt.tokens : [Token.Raw(separator), Token.Raw(NEWLINE), ...stmt.tokens]
109
+ )
110
+ );
111
+ }
112
+ addSeparated(input, separator = SEPARATE) {
113
+ return this.space().separated(input, separator);
114
+ }
115
+ isEmpty() {
116
+ return this.tokens.length === 0 || this.tokens.length === 1 && this.tokens[0].type === "Raw" /* Raw */ && this.tokens[0].data === "";
117
+ }
118
+ compile(sanitizer, formatInline = false) {
119
+ let sql = "", params = [], indent = "";
120
+ for (const token of this.tokens) {
121
+ switch (token.type) {
122
+ case "Raw" /* Raw */:
123
+ if (token.data === NEWLINE)
124
+ sql += NEWLINE + indent;
125
+ else
126
+ sql += token.data;
127
+ break;
128
+ case "Identifier" /* Identifier */:
129
+ sql += sanitizer.escapeIdent(token.data);
130
+ break;
131
+ case "Value" /* Value */:
132
+ if (formatInline) {
133
+ sql += sanitizer.escapeValue(token.data);
134
+ } else {
135
+ sql += "?";
136
+ params.push(token.data === void 0 ? null : token.data);
137
+ }
138
+ break;
139
+ case "Indent" /* Indent */:
140
+ indent += " ";
141
+ break;
142
+ case "Dedent" /* Dedent */:
143
+ indent = indent.slice(0, -2);
144
+ break;
145
+ }
146
+ }
147
+ return [sql, params];
148
+ }
149
+ };
150
+ function newline() {
151
+ return new Statement([Token.Raw(NEWLINE)]);
152
+ }
153
+ function raw(raw2) {
154
+ return new Statement([Token.Raw(raw2)]);
155
+ }
156
+ function identifier(name) {
157
+ return new Statement([Token.Identifier(name)]);
158
+ }
159
+ function value(value2) {
160
+ return new Statement([Token.Value(value2)]);
161
+ }
162
+ function empty() {
163
+ return new Statement([]);
164
+ }
165
+ function parenthesis(stmnt) {
166
+ return empty().parenthesis(stmnt);
167
+ }
168
+ function call(method, ...args) {
169
+ return identifier(method).parenthesis(separated(args));
170
+ }
171
+ function separated(input, separator = SEPARATE) {
172
+ return empty().separated(input, separator);
173
+ }
174
+ export {
175
+ Statement,
176
+ call,
177
+ empty,
178
+ identifier,
179
+ newline,
180
+ parenthesis,
181
+ raw,
182
+ separated,
183
+ value
184
+ };
@@ -0,0 +1,47 @@
1
+ import { Column } from './Column';
2
+ import { Cursor } from './Cursor';
3
+ import { Expr } from './Expr';
4
+ import { Fields } from './Fields';
5
+ import { Schema } from './Schema';
6
+ import { Update } from './Update';
7
+ export declare class Table<T> extends Cursor.SelectMultiple<T> {
8
+ /** @internal */
9
+ protected __tableType: T;
10
+ constructor(schema: Schema);
11
+ insertOne(record: Table.Insert<T>): Cursor.Batch<T>;
12
+ insertAll(data: Array<Table.Insert<T>>): Cursor.InsertValues;
13
+ set(data: Update<T>): Cursor.Update<T>;
14
+ createTable(): Cursor.Create;
15
+ as(alias: string): Table<T> & Fields<T>;
16
+ get(name: string): Expr<any>;
17
+ toExpr(): Expr<T>;
18
+ schema(): Schema;
19
+ }
20
+ export declare namespace Table {
21
+ type Intersection<A, B> = A & B extends infer U ? {
22
+ [P in keyof U]: U[P];
23
+ } : never;
24
+ type OptionalKeys<T> = {
25
+ [K in keyof T]: null extends T[K] ? K : T[K] extends Column.Optional ? K : never;
26
+ }[keyof T];
27
+ type RequiredKeys<T> = {
28
+ [K in keyof T]: null extends T[K] ? never : T[K] extends Column.Optional ? never : K;
29
+ }[keyof T];
30
+ type Optionals<T> = {
31
+ [K in keyof T]?: T[K] extends Column.Optional & infer V ? V : T[K];
32
+ };
33
+ export type Insert<T> = Intersection<Optionals<Pick<T, OptionalKeys<T>>>, Pick<T, RequiredKeys<T>>>;
34
+ export {};
35
+ }
36
+ export interface TableOptions<T> {
37
+ name: string;
38
+ alias?: string;
39
+ columns: {
40
+ [K in keyof T]: Column<T[K]>;
41
+ };
42
+ indexes?: Record<string, Array<Expr<any>>>;
43
+ }
44
+ export declare function table<T extends {}>(options: TableOptions<T>): Table<T> & Fields<T>;
45
+ export declare namespace table {
46
+ type infer<T> = T extends Table<infer U> ? U : never;
47
+ }
package/dist/Table.js ADDED
@@ -0,0 +1,82 @@
1
+ // src/Table.ts
2
+ import { Cursor } from "./Cursor";
3
+ import { Expr, ExprData } from "./Expr";
4
+ import { Query } from "./Query";
5
+ import { Target } from "./Target";
6
+ var Table = class extends Cursor.SelectMultiple {
7
+ constructor(data) {
8
+ super(
9
+ Query.Select({
10
+ from: Target.Table(data),
11
+ selection: ExprData.Row(Target.Table(data))
12
+ })
13
+ );
14
+ Object.defineProperty(this, "data", {
15
+ enumerable: false,
16
+ value: () => data
17
+ });
18
+ if (data.columns)
19
+ for (const column of Object.keys(data.columns)) {
20
+ Object.defineProperty(this, column, {
21
+ enumerable: true,
22
+ get: () => this.get(column)
23
+ });
24
+ }
25
+ return new Proxy(this, {
26
+ get(target, key) {
27
+ return key in target ? target[key] : target.get(key);
28
+ }
29
+ });
30
+ }
31
+ insertOne(record) {
32
+ return new Cursor.Batch([
33
+ Query.Insert({
34
+ into: this.data(),
35
+ data: [record],
36
+ selection: ExprData.Row(Target.Table(this.data())),
37
+ singleResult: true
38
+ })
39
+ ]);
40
+ }
41
+ insertAll(data) {
42
+ return new Cursor.Insert(this.data()).values(...data);
43
+ }
44
+ set(data) {
45
+ return new Cursor.Update(
46
+ Query.Update({
47
+ table: this.data()
48
+ })
49
+ ).set(data);
50
+ }
51
+ createTable() {
52
+ return new Cursor.Create(this.data());
53
+ }
54
+ as(alias) {
55
+ return new Table({ ...this.data(), alias });
56
+ }
57
+ get(name) {
58
+ return new Expr(ExprData.Field(this.toExpr().expr, name));
59
+ }
60
+ toExpr() {
61
+ return new Expr(ExprData.Row(Target.Table(this.data())));
62
+ }
63
+ /** @internal */
64
+ data() {
65
+ throw new Error("Not implemented");
66
+ }
67
+ };
68
+ function table(options) {
69
+ return new Table({
70
+ ...options,
71
+ columns: Object.fromEntries(
72
+ Object.entries(options.columns).map(([key, column]) => {
73
+ const { data } = column;
74
+ return [key, { ...data, name: data.name || key }];
75
+ })
76
+ )
77
+ });
78
+ }
79
+ export {
80
+ Table,
81
+ table
82
+ };
@@ -0,0 +1,30 @@
1
+ import { ExprData } from './Expr';
2
+ import { Schema } from './Schema';
3
+ export declare const enum TargetType {
4
+ Each = "Each",
5
+ Table = "Table",
6
+ Join = "Join"
7
+ }
8
+ export type Target = Target.Each | Target.Table | Target.Join;
9
+ export declare namespace Target {
10
+ interface Each {
11
+ type: TargetType.Each;
12
+ expr: ExprData;
13
+ alias: string;
14
+ }
15
+ function Each(expr: ExprData, alias: string): Each;
16
+ interface Table {
17
+ type: TargetType.Table;
18
+ table: Schema;
19
+ }
20
+ function Table(table: Schema): Table;
21
+ interface Join {
22
+ type: TargetType.Join;
23
+ left: Target;
24
+ right: Target;
25
+ joinType: 'left' | 'inner';
26
+ on: ExprData;
27
+ }
28
+ function Join(left: Target, right: Target, joinType: 'left' | 'inner', on: ExprData): Join;
29
+ function source(from: Target): Schema | undefined;
30
+ }
package/dist/Target.js ADDED
@@ -0,0 +1,37 @@
1
+ // src/Target.ts
2
+ var TargetType = /* @__PURE__ */ ((TargetType2) => {
3
+ TargetType2["Each"] = "Each";
4
+ TargetType2["Table"] = "Table";
5
+ TargetType2["Join"] = "Join";
6
+ return TargetType2;
7
+ })(TargetType || {});
8
+ var Target;
9
+ ((Target2) => {
10
+ function Each(expr, alias) {
11
+ return { type: "Each" /* Each */, expr, alias };
12
+ }
13
+ Target2.Each = Each;
14
+ function Table(table) {
15
+ return { type: "Table" /* Table */, table };
16
+ }
17
+ Target2.Table = Table;
18
+ function Join(left, right, joinType, on) {
19
+ return { type: "Join" /* Join */, left, right, joinType, on };
20
+ }
21
+ Target2.Join = Join;
22
+ function source(from) {
23
+ switch (from.type) {
24
+ case "Table" /* Table */:
25
+ return from.table;
26
+ case "Join" /* Join */:
27
+ return source(from.left);
28
+ default:
29
+ return void 0;
30
+ }
31
+ }
32
+ Target2.source = source;
33
+ })(Target || (Target = {}));
34
+ export {
35
+ Target,
36
+ TargetType
37
+ };
@@ -0,0 +1,4 @@
1
+ import type { EV } from './Expr';
2
+ export type Update<Row> = Partial<{
3
+ [K in keyof Row]: EV<Row[K]>;
4
+ }>;
package/dist/Update.js ADDED
File without changes
@@ -1,17 +1,17 @@
1
- import type { Database } from 'better-sqlite3';
2
- import { Driver } from '../lib/Driver';
3
- import { SchemaInstructions } from '../lib/Schema';
4
- import { Statement } from '../lib/Statement';
5
- export declare class BetterSqlite3Driver extends Driver.Sync {
6
- db: Database;
7
- constructor(db: Database);
8
- rows<T extends object = object>([sql, params]: Statement.Compiled): Array<T>;
9
- values([sql, params]: Statement.Compiled): Array<Array<any>>;
10
- execute([sql, params]: Statement.Compiled): void;
11
- mutate([sql, params]: Statement.Compiled): {
12
- rowsAffected: number;
13
- };
14
- schemaInstructions(tableName: string): SchemaInstructions | undefined;
15
- export(): Uint8Array;
16
- }
17
- export declare function connect(db: Database): BetterSqlite3Driver;
1
+ import type { Database } from 'better-sqlite3';
2
+ import { Driver } from '../lib/Driver';
3
+ import { SchemaInstructions } from '../lib/Schema';
4
+ import { Statement } from '../lib/Statement';
5
+ export declare class BetterSqlite3Driver extends Driver.Sync {
6
+ db: Database;
7
+ constructor(db: Database);
8
+ rows<T extends object = object>([sql, params]: Statement.Compiled): Array<T>;
9
+ values([sql, params]: Statement.Compiled): Array<Array<any>>;
10
+ execute([sql, params]: Statement.Compiled): void;
11
+ mutate([sql, params]: Statement.Compiled): {
12
+ rowsAffected: number;
13
+ };
14
+ schemaInstructions(tableName: string): SchemaInstructions | undefined;
15
+ export(): Uint8Array;
16
+ }
17
+ export declare function connect(db: Database): BetterSqlite3Driver;
@@ -1,17 +1,17 @@
1
- import type { Database } from 'sql.js';
2
- import { Driver } from '../lib/Driver';
3
- import { SchemaInstructions } from '../lib/Schema';
4
- import { Statement } from '../lib/Statement';
5
- export declare class SqlJsDriver extends Driver.Sync {
6
- db: Database;
7
- constructor(db: Database);
8
- rows<T extends object = object>([sql, params]: Statement.Compiled): Array<T>;
9
- values([sql, params]: Statement.Compiled): Array<Array<any>>;
10
- execute([sql, params]: Statement.Compiled): void;
11
- mutate([sql, params]: Statement.Compiled): {
12
- rowsAffected: number;
13
- };
14
- schemaInstructions(tableName: string): SchemaInstructions | undefined;
15
- export(): Uint8Array;
16
- }
17
- export declare function connect(db: Database): SqlJsDriver;
1
+ import type { Database } from 'sql.js';
2
+ import { Driver } from '../lib/Driver';
3
+ import { SchemaInstructions } from '../lib/Schema';
4
+ import { Statement } from '../lib/Statement';
5
+ export declare class SqlJsDriver extends Driver.Sync {
6
+ db: Database;
7
+ constructor(db: Database);
8
+ rows<T extends object = object>([sql, params]: Statement.Compiled): Array<T>;
9
+ values([sql, params]: Statement.Compiled): Array<Array<any>>;
10
+ execute([sql, params]: Statement.Compiled): void;
11
+ mutate([sql, params]: Statement.Compiled): {
12
+ rowsAffected: number;
13
+ };
14
+ schemaInstructions(tableName: string): SchemaInstructions | undefined;
15
+ export(): Uint8Array;
16
+ }
17
+ export declare function connect(db: Database): SqlJsDriver;
@@ -1,20 +1,20 @@
1
- import type { Database } from 'sqlite3';
2
- import { Driver } from '../lib/Driver';
3
- import { Query } from '../lib/Query';
4
- import { SchemaInstructions } from '../lib/Schema';
5
- import { Statement } from '../lib/Statement';
6
- export declare class Sqlite3Driver extends Driver.Async {
7
- private db;
8
- lock: Promise<void> | undefined;
9
- constructor(db: Database);
10
- executeQuery<T>(query: Query<T>): Promise<T>;
11
- rows<T extends object = object>([sql, params]: Statement.Compiled): Promise<Array<T>>;
12
- values(stmt: Statement.Compiled): Promise<Array<Array<any>>>;
13
- execute([sql, params]: Statement.Compiled): Promise<void>;
14
- mutate([sql, params]: Statement.Compiled): Promise<{
15
- rowsAffected: number;
16
- }>;
17
- schemaInstructions(tableName: string): Promise<SchemaInstructions | undefined>;
18
- isolate(): [connection: Driver.Async, release: () => Promise<void>];
19
- }
20
- export declare function connect(db: Database): Sqlite3Driver;
1
+ import type { Database } from 'sqlite3';
2
+ import { Driver } from '../lib/Driver';
3
+ import { Query } from '../lib/Query';
4
+ import { SchemaInstructions } from '../lib/Schema';
5
+ import { Statement } from '../lib/Statement';
6
+ export declare class Sqlite3Driver extends Driver.Async {
7
+ private db;
8
+ lock: Promise<void> | undefined;
9
+ constructor(db: Database);
10
+ executeQuery<T>(query: Query<T>): Promise<T>;
11
+ rows<T extends object = object>([sql, params]: Statement.Compiled): Promise<Array<T>>;
12
+ values(stmt: Statement.Compiled): Promise<Array<Array<any>>>;
13
+ execute([sql, params]: Statement.Compiled): Promise<void>;
14
+ mutate([sql, params]: Statement.Compiled): Promise<{
15
+ rowsAffected: number;
16
+ }>;
17
+ schemaInstructions(tableName: string): Promise<SchemaInstructions | undefined>;
18
+ isolate(): [connection: Driver.Async, release: () => Promise<void>];
19
+ }
20
+ export declare function connect(db: Database): Sqlite3Driver;