rado 0.1.23 → 0.1.25
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/README.md +1 -1
- package/dist/driver/better-sqlite3.d.ts +15 -17
- package/dist/driver/better-sqlite3.js +25 -18
- package/dist/driver/sql.js.d.ts +15 -17
- package/dist/driver/sql.js.js +29 -26
- package/dist/driver/sqlite3.d.ts +18 -20
- package/dist/driver/sqlite3.js +40 -29
- package/dist/index.d.ts +20 -20
- package/dist/lib/Column.d.ts +57 -57
- package/dist/lib/Cursor.d.ts +78 -77
- package/dist/lib/Cursor.js +3 -0
- package/dist/lib/Driver.d.ts +105 -89
- package/dist/lib/Driver.js +72 -28
- package/dist/lib/Expr.d.ts +154 -154
- package/dist/lib/Fields.d.ts +13 -13
- package/dist/lib/Formatter.d.ts +56 -56
- package/dist/lib/Formatter.js +14 -4
- package/dist/lib/Functions.d.ts +7 -7
- package/dist/lib/Id.d.ts +3 -3
- package/dist/lib/Index.d.ts +17 -17
- package/dist/lib/Index.js +3 -3
- package/dist/lib/Ops.d.ts +8 -8
- package/dist/lib/OrderBy.d.ts +9 -9
- package/dist/lib/Param.d.ts +20 -15
- package/dist/lib/Param.js +10 -1
- package/dist/lib/Query.d.ts +108 -108
- package/dist/lib/Sanitizer.d.ts +4 -4
- package/dist/lib/Schema.d.ts +18 -18
- package/dist/lib/Schema.js +4 -4
- package/dist/lib/Selection.d.ts +20 -20
- package/dist/lib/Statement.d.ts +71 -61
- package/dist/lib/Statement.js +46 -5
- package/dist/lib/Table.d.ts +59 -58
- package/dist/lib/Table.js +4 -7
- package/dist/lib/Target.d.ts +30 -30
- package/dist/lib/Update.d.ts +4 -4
- package/dist/sqlite/SqliteFormatter.d.ts +11 -11
- package/dist/sqlite/SqliteFunctions.d.ts +156 -156
- package/dist/sqlite/SqliteSchema.d.ts +25 -24
- package/dist/sqlite/SqliteSchema.js +5 -4
- package/dist/sqlite.d.ts +2 -2
- package/package.json +47 -47
- package/dist/Column.d.ts +0 -41
- package/dist/Column.js +0 -58
- package/dist/Cursor.d.ts +0 -77
- package/dist/Cursor.js +0 -211
- package/dist/Driver.d.ts +0 -72
- package/dist/Driver.js +0 -145
- package/dist/Expr.d.ts +0 -149
- package/dist/Expr.js +0 -284
- package/dist/Fields.d.ts +0 -9
- package/dist/Fields.js +0 -0
- package/dist/Formatter.d.ts +0 -50
- package/dist/Formatter.js +0 -453
- package/dist/Functions.d.ts +0 -8
- package/dist/Functions.js +0 -11
- package/dist/Key.d.ts +0 -5
- package/dist/Ops.d.ts +0 -8
- package/dist/Ops.js +0 -46
- package/dist/OrderBy.d.ts +0 -9
- package/dist/OrderBy.js +0 -9
- package/dist/Param.d.ts +0 -15
- package/dist/Param.js +0 -18
- package/dist/Query.d.ts +0 -94
- package/dist/Query.js +0 -57
- package/dist/Sanitizer.d.ts +0 -4
- package/dist/Sanitizer.js +0 -0
- package/dist/Schema.d.ts +0 -10
- package/dist/Selection.d.ts +0 -18
- package/dist/Selection.js +0 -0
- package/dist/Statement.d.ts +0 -57
- package/dist/Statement.js +0 -184
- package/dist/Table.d.ts +0 -47
- package/dist/Table.js +0 -82
- package/dist/Target.d.ts +0 -30
- package/dist/Target.js +0 -37
- package/dist/Update.d.ts +0 -4
- package/dist/Update.js +0 -0
- package/dist/sqlite/index.d.ts +0 -2
- package/dist/sqlite/index.js +0 -3
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
function
|
|
22
|
-
function
|
|
23
|
-
function
|
|
24
|
-
|
|
1
|
+
import { Cursor } from '../lib/Cursor';
|
|
2
|
+
import { Expr } from '../lib/Expr';
|
|
3
|
+
import { SchemaInstructions } from '../lib/Schema';
|
|
4
|
+
export declare namespace SqliteSchema {
|
|
5
|
+
type Column = {
|
|
6
|
+
cid: number;
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
notnull: number;
|
|
10
|
+
dflt_value: string | null;
|
|
11
|
+
pk: number;
|
|
12
|
+
};
|
|
13
|
+
interface Index {
|
|
14
|
+
type: 'index';
|
|
15
|
+
name: string;
|
|
16
|
+
tbl_name: string;
|
|
17
|
+
rootpage: number;
|
|
18
|
+
sql: string;
|
|
19
|
+
}
|
|
20
|
+
function tableData(tableName: Expr<string>): Cursor<Array<SqliteSchema.Column>>;
|
|
21
|
+
function indexData(tableName: Expr<string>): Cursor<Array<SqliteSchema.Index>>;
|
|
22
|
+
function createInstructions(columnData: Array<Column>, indexData: Array<Index>): SchemaInstructions | undefined;
|
|
23
|
+
function columnInstruction(column: Column): [string, string];
|
|
24
|
+
function indexInstruction(index: Index): [string, string];
|
|
25
|
+
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// src/sqlite/SqliteSchema.ts
|
|
2
|
-
import {
|
|
2
|
+
import { Cursor } from "../lib/Cursor.js";
|
|
3
|
+
import { identifier, raw } from "../lib/Statement.js";
|
|
3
4
|
import { SqliteFormatter } from "./SqliteFormatter.js";
|
|
4
5
|
var SqliteSchema;
|
|
5
6
|
((SqliteSchema2) => {
|
|
6
7
|
const formatter = new SqliteFormatter();
|
|
7
8
|
function tableData(tableName) {
|
|
8
|
-
return
|
|
9
|
+
return Cursor.all`select * from pragma_table_info(${tableName}) order by cid`;
|
|
9
10
|
}
|
|
10
11
|
SqliteSchema2.tableData = tableData;
|
|
11
12
|
function indexData(tableName) {
|
|
12
|
-
return
|
|
13
|
+
return Cursor.all`select * from sqlite_master where type='index' and tbl_name=${tableName}`;
|
|
13
14
|
}
|
|
14
15
|
SqliteSchema2.indexData = indexData;
|
|
15
16
|
function createInstructions(columnData, indexData2) {
|
|
@@ -29,7 +30,7 @@ var SqliteSchema;
|
|
|
29
30
|
identifier(column.name).add(column.type).addIf(column.pk === 1, "PRIMARY KEY").addIf(column.notnull === 1, "NOT NULL").addIf(
|
|
30
31
|
column.dflt_value !== null,
|
|
31
32
|
raw("DEFAULT").addParenthesis(column.dflt_value)
|
|
32
|
-
).compile(formatter)
|
|
33
|
+
).compile(formatter).sql
|
|
33
34
|
];
|
|
34
35
|
}
|
|
35
36
|
SqliteSchema2.columnInstruction = columnInstruction;
|
package/dist/sqlite.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './sqlite/SqliteFormatter';
|
|
2
|
-
export * from './sqlite/SqliteFunctions';
|
|
1
|
+
export * from './sqlite/SqliteFormatter';
|
|
2
|
+
export * from './sqlite/SqliteFunctions';
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "rado",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": "./dist/index.js",
|
|
8
|
-
"./*": "./dist/*.js"
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
|
-
"sideEffects": false,
|
|
14
|
-
"typesVersions": {
|
|
15
|
-
"*": {
|
|
16
|
-
"*": [
|
|
17
|
-
"./dist/*"
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsc -p tsconfig.build.json && tsx build.ts",
|
|
23
|
-
"test": "tsx test",
|
|
24
|
-
"prepublishOnly": "tsc -p tsconfig.build.json && tsx build.ts"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/better-sqlite3": "^5.4.1",
|
|
28
|
-
"@types/glob": "^8.0.0",
|
|
29
|
-
"@types/sql.js": "^1.4.2",
|
|
30
|
-
"better-sqlite3": "^7.5.1",
|
|
31
|
-
"esbuild": "^0.16.16",
|
|
32
|
-
"glob": "^8.0.3",
|
|
33
|
-
"sade": "^1.8.1",
|
|
34
|
-
"sql.js": "^1.8.0",
|
|
35
|
-
"sqlite3": "^5.1.4",
|
|
36
|
-
"tsx": "^3.12.1",
|
|
37
|
-
"typescript": "next",
|
|
38
|
-
"uvu": "^0.5.6"
|
|
39
|
-
},
|
|
40
|
-
"volta": {
|
|
41
|
-
"node": "18.12.1"
|
|
42
|
-
},
|
|
43
|
-
"packageManager": "yarn@3.3.1",
|
|
44
|
-
"resolutions": {
|
|
45
|
-
"esbuild": "0.16.16"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "rado",
|
|
3
|
+
"version": "0.1.25",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/index.js",
|
|
8
|
+
"./*": "./dist/*.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"typesVersions": {
|
|
15
|
+
"*": {
|
|
16
|
+
"*": [
|
|
17
|
+
"./dist/*"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -p tsconfig.build.json && tsx build.ts",
|
|
23
|
+
"test": "tsx test",
|
|
24
|
+
"prepublishOnly": "tsc -p tsconfig.build.json && tsx build.ts"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/better-sqlite3": "^5.4.1",
|
|
28
|
+
"@types/glob": "^8.0.0",
|
|
29
|
+
"@types/sql.js": "^1.4.2",
|
|
30
|
+
"better-sqlite3": "^7.5.1",
|
|
31
|
+
"esbuild": "^0.16.16",
|
|
32
|
+
"glob": "^8.0.3",
|
|
33
|
+
"sade": "^1.8.1",
|
|
34
|
+
"sql.js": "^1.8.0",
|
|
35
|
+
"sqlite3": "^5.1.4",
|
|
36
|
+
"tsx": "^3.12.1",
|
|
37
|
+
"typescript": "next",
|
|
38
|
+
"uvu": "^0.5.6"
|
|
39
|
+
},
|
|
40
|
+
"volta": {
|
|
41
|
+
"node": "18.12.1"
|
|
42
|
+
},
|
|
43
|
+
"packageManager": "yarn@3.3.1",
|
|
44
|
+
"resolutions": {
|
|
45
|
+
"esbuild": "0.16.16"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/Column.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export declare const enum ColumnType {
|
|
2
|
-
String = "String",
|
|
3
|
-
Integer = "Integer",
|
|
4
|
-
Number = "Number",
|
|
5
|
-
Boolean = "Boolean",
|
|
6
|
-
Json = "Json"
|
|
7
|
-
}
|
|
8
|
-
export interface ColumnData {
|
|
9
|
-
type: ColumnType;
|
|
10
|
-
name?: string;
|
|
11
|
-
nullable?: boolean;
|
|
12
|
-
defaultValue?: any;
|
|
13
|
-
autoIncrement?: boolean;
|
|
14
|
-
primaryKey?: boolean;
|
|
15
|
-
unique?: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare class Column<T = any> {
|
|
18
|
-
data: ColumnData;
|
|
19
|
-
constructor(data: ColumnData);
|
|
20
|
-
name(name: string): Column<T>;
|
|
21
|
-
nullable(): Column<T | null>;
|
|
22
|
-
autoIncrement(): Column<T & Column.Optional>;
|
|
23
|
-
primaryKey(): Column<T & Column.Optional>;
|
|
24
|
-
unique(): Column<T>;
|
|
25
|
-
defaultValue(value: T): Column<T & Column.Optional>;
|
|
26
|
-
}
|
|
27
|
-
export declare namespace Column {
|
|
28
|
-
const isOptional: unique symbol;
|
|
29
|
-
export type Optional = {
|
|
30
|
-
[isOptional]: true;
|
|
31
|
-
};
|
|
32
|
-
export {};
|
|
33
|
-
}
|
|
34
|
-
export declare const column: {
|
|
35
|
-
string<T extends string = string>(): Column<T>;
|
|
36
|
-
integer<T_1 extends number = number>(): Column<T_1>;
|
|
37
|
-
number<T_2 extends number = number>(): Column<T_2>;
|
|
38
|
-
boolean<T_3 extends boolean = boolean>(): Column<T_3>;
|
|
39
|
-
object<T_4 extends object = object>(): Column<T_4>;
|
|
40
|
-
array<T_5 = any>(): Column<T_5[]>;
|
|
41
|
-
};
|
package/dist/Column.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// src/Column.ts
|
|
2
|
-
var ColumnType = /* @__PURE__ */ ((ColumnType2) => {
|
|
3
|
-
ColumnType2["String"] = "String";
|
|
4
|
-
ColumnType2["Integer"] = "Integer";
|
|
5
|
-
ColumnType2["Number"] = "Number";
|
|
6
|
-
ColumnType2["Boolean"] = "Boolean";
|
|
7
|
-
ColumnType2["Object"] = "Object";
|
|
8
|
-
ColumnType2["Array"] = "Array";
|
|
9
|
-
return ColumnType2;
|
|
10
|
-
})(ColumnType || {});
|
|
11
|
-
var Column = class {
|
|
12
|
-
constructor(data) {
|
|
13
|
-
this.data = data;
|
|
14
|
-
}
|
|
15
|
-
name(name) {
|
|
16
|
-
return new Column({ ...this.data, name });
|
|
17
|
-
}
|
|
18
|
-
nullable() {
|
|
19
|
-
return new Column({ ...this.data, nullable: true });
|
|
20
|
-
}
|
|
21
|
-
autoIncrement() {
|
|
22
|
-
return new Column({ ...this.data, autoIncrement: true });
|
|
23
|
-
}
|
|
24
|
-
primaryKey() {
|
|
25
|
-
return new Column({ ...this.data, primaryKey: true });
|
|
26
|
-
}
|
|
27
|
-
unique() {
|
|
28
|
-
return new Column({ ...this.data, unique: true });
|
|
29
|
-
}
|
|
30
|
-
defaultValue(value) {
|
|
31
|
-
return new Column({ ...this.data, defaultValue: value });
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
var column = {
|
|
35
|
-
string() {
|
|
36
|
-
return new Column({ type: "String" /* String */ });
|
|
37
|
-
},
|
|
38
|
-
integer() {
|
|
39
|
-
return new Column({ type: "Integer" /* Integer */ });
|
|
40
|
-
},
|
|
41
|
-
number() {
|
|
42
|
-
return new Column({ type: "Number" /* Number */ });
|
|
43
|
-
},
|
|
44
|
-
boolean() {
|
|
45
|
-
return new Column({ type: "Boolean" /* Boolean */ });
|
|
46
|
-
},
|
|
47
|
-
object() {
|
|
48
|
-
return new Column({ type: "Object" /* Object */ });
|
|
49
|
-
},
|
|
50
|
-
array() {
|
|
51
|
-
return new Column({ type: "Array" /* Array */ });
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
export {
|
|
55
|
-
Column,
|
|
56
|
-
ColumnType,
|
|
57
|
-
column
|
|
58
|
-
};
|
package/dist/Cursor.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { EV, Expr } from './Expr';
|
|
2
|
-
import { OrderBy } from './OrderBy';
|
|
3
|
-
import { Query } from './Query';
|
|
4
|
-
import { Schema } from './Schema';
|
|
5
|
-
import { Selection } from './Selection';
|
|
6
|
-
import { Table } from './Table';
|
|
7
|
-
import { Update as UpdateSet } from './Update';
|
|
8
|
-
export declare class Cursor<T> {
|
|
9
|
-
/** @internal */
|
|
10
|
-
protected __cursorType: T;
|
|
11
|
-
constructor(query: Query<T>);
|
|
12
|
-
query(): Query<T>;
|
|
13
|
-
toJSON(): Query<T>;
|
|
14
|
-
}
|
|
15
|
-
export declare namespace Cursor {
|
|
16
|
-
class Limitable<T> extends Cursor<T> {
|
|
17
|
-
take(limit: number | undefined): Limitable<T>;
|
|
18
|
-
skip(offset: number | undefined): Limitable<T>;
|
|
19
|
-
}
|
|
20
|
-
class Filterable<T> extends Limitable<T> {
|
|
21
|
-
where(...where: Array<EV<boolean>>): Filterable<T>;
|
|
22
|
-
}
|
|
23
|
-
class Delete<T> extends Filterable<{
|
|
24
|
-
rowsAffected: number;
|
|
25
|
-
}> {
|
|
26
|
-
query(): Query.Delete;
|
|
27
|
-
}
|
|
28
|
-
class Update<T> extends Filterable<{
|
|
29
|
-
rowsAffected: number;
|
|
30
|
-
}> {
|
|
31
|
-
query: () => Query.Update;
|
|
32
|
-
set(set: UpdateSet<T>): Update<T>;
|
|
33
|
-
}
|
|
34
|
-
class InsertValuesReturning<T> extends Cursor<T> {
|
|
35
|
-
}
|
|
36
|
-
class InsertValues extends Cursor<{
|
|
37
|
-
rowsAffected: number;
|
|
38
|
-
}> {
|
|
39
|
-
query(): Query.Insert;
|
|
40
|
-
returning<X extends Selection>(selection: X): InsertValuesReturning<Selection.Infer<X>>;
|
|
41
|
-
}
|
|
42
|
-
class Insert<T> {
|
|
43
|
-
protected into: Schema;
|
|
44
|
-
constructor(into: Schema);
|
|
45
|
-
values(...data: Array<Table.Insert<T>>): InsertValues;
|
|
46
|
-
}
|
|
47
|
-
class Create extends Cursor<void> {
|
|
48
|
-
protected table: Schema;
|
|
49
|
-
constructor(table: Schema);
|
|
50
|
-
}
|
|
51
|
-
class Batch<T = void> extends Cursor<T> {
|
|
52
|
-
protected queries: Array<Query>;
|
|
53
|
-
constructor(queries: Array<Query>);
|
|
54
|
-
}
|
|
55
|
-
class SelectMultiple<T> extends Filterable<Array<T>> {
|
|
56
|
-
query(): Query.Select;
|
|
57
|
-
leftJoin<C>(that: Table<C>, ...on: Array<EV<boolean>>): SelectMultiple<T>;
|
|
58
|
-
innerJoin<C>(that: Table<C>, ...on: Array<EV<boolean>>): SelectMultiple<T>;
|
|
59
|
-
select<X extends Selection>(selection: X): SelectMultiple<Selection.Infer<X>>;
|
|
60
|
-
count(): SelectSingle<number>;
|
|
61
|
-
orderBy(...orderBy: Array<OrderBy>): SelectMultiple<T>;
|
|
62
|
-
groupBy(...groupBy: Array<Expr<any>>): SelectMultiple<T>;
|
|
63
|
-
first(): SelectSingle<T | undefined>;
|
|
64
|
-
where(...where: Array<EV<boolean>>): SelectMultiple<T>;
|
|
65
|
-
toExpr(): Expr<T>;
|
|
66
|
-
}
|
|
67
|
-
class SelectSingle<T> extends Filterable<T> {
|
|
68
|
-
query(): Query.Select;
|
|
69
|
-
leftJoin<C>(that: Table<C>, ...on: Array<EV<boolean>>): SelectSingle<T>;
|
|
70
|
-
innerJoin<C>(that: Table<C>, ...on: Array<EV<boolean>>): SelectSingle<T>;
|
|
71
|
-
select<X extends Selection>(selection: X): SelectSingle<Selection.Infer<X>>;
|
|
72
|
-
orderBy(...orderBy: Array<OrderBy>): SelectSingle<T>;
|
|
73
|
-
groupBy(...groupBy: Array<Expr<any>>): SelectSingle<T>;
|
|
74
|
-
where(...where: Array<EV<boolean>>): SelectSingle<T>;
|
|
75
|
-
toExpr(): Expr<T>;
|
|
76
|
-
}
|
|
77
|
-
}
|
package/dist/Cursor.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
// src/Cursor.ts
|
|
2
|
-
import { Expr, ExprData } from "./Expr";
|
|
3
|
-
import { Functions } from "./Functions";
|
|
4
|
-
import { Query } from "./Query";
|
|
5
|
-
import { Target } from "./Target";
|
|
6
|
-
var Cursor = class {
|
|
7
|
-
constructor(query) {
|
|
8
|
-
Object.defineProperty(this, "query", {
|
|
9
|
-
enumerable: false,
|
|
10
|
-
value: () => query
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
query() {
|
|
14
|
-
throw new Error("Not implemented");
|
|
15
|
-
}
|
|
16
|
-
toJSON() {
|
|
17
|
-
return this.query();
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
((Cursor2) => {
|
|
21
|
-
class Limitable extends Cursor2 {
|
|
22
|
-
take(limit) {
|
|
23
|
-
return new Limitable({ ...this.query(), limit });
|
|
24
|
-
}
|
|
25
|
-
skip(offset) {
|
|
26
|
-
return new Limitable({ ...this.query(), offset });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
Cursor2.Limitable = Limitable;
|
|
30
|
-
class Filterable extends Limitable {
|
|
31
|
-
where(...where) {
|
|
32
|
-
const condition = Expr.and(...where);
|
|
33
|
-
const query = this.query();
|
|
34
|
-
return new Filterable({
|
|
35
|
-
...query,
|
|
36
|
-
where: (query.where ? condition.and(new Expr(query.where)) : condition).expr
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
Cursor2.Filterable = Filterable;
|
|
41
|
-
class Delete extends Filterable {
|
|
42
|
-
query() {
|
|
43
|
-
return super.query();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
Cursor2.Delete = Delete;
|
|
47
|
-
class Update extends Filterable {
|
|
48
|
-
set(set) {
|
|
49
|
-
return new Update({ ...this.query(), set });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
Cursor2.Update = Update;
|
|
53
|
-
class InsertValuesReturning extends Cursor2 {
|
|
54
|
-
}
|
|
55
|
-
Cursor2.InsertValuesReturning = InsertValuesReturning;
|
|
56
|
-
class InsertValues extends Cursor2 {
|
|
57
|
-
query() {
|
|
58
|
-
return super.query();
|
|
59
|
-
}
|
|
60
|
-
returning(selection) {
|
|
61
|
-
return new InsertValuesReturning(
|
|
62
|
-
Query.Insert({ ...this.query(), selection: ExprData.create(selection) })
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
Cursor2.InsertValues = InsertValues;
|
|
67
|
-
class Insert {
|
|
68
|
-
constructor(into) {
|
|
69
|
-
this.into = into;
|
|
70
|
-
}
|
|
71
|
-
values(...data) {
|
|
72
|
-
return new InsertValues(Query.Insert({ into: this.into, data }));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
Cursor2.Insert = Insert;
|
|
76
|
-
class Create extends Cursor2 {
|
|
77
|
-
constructor(table) {
|
|
78
|
-
super(Query.CreateTable({ table, ifNotExists: true }));
|
|
79
|
-
this.table = table;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
Cursor2.Create = Create;
|
|
83
|
-
class Batch extends Cursor2 {
|
|
84
|
-
constructor(queries) {
|
|
85
|
-
super(Query.Batch({ queries }));
|
|
86
|
-
this.queries = queries;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
Cursor2.Batch = Batch;
|
|
90
|
-
class SelectMultiple extends Filterable {
|
|
91
|
-
query() {
|
|
92
|
-
return super.query();
|
|
93
|
-
}
|
|
94
|
-
leftJoin(that, ...on) {
|
|
95
|
-
const query = this.query();
|
|
96
|
-
return new SelectMultiple({
|
|
97
|
-
...query,
|
|
98
|
-
from: Target.Join(
|
|
99
|
-
query.from,
|
|
100
|
-
Target.Table(that.data()),
|
|
101
|
-
"left",
|
|
102
|
-
Expr.and(...on).expr
|
|
103
|
-
)
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
innerJoin(that, ...on) {
|
|
107
|
-
const query = this.query();
|
|
108
|
-
return new SelectMultiple({
|
|
109
|
-
...query,
|
|
110
|
-
from: Target.Join(
|
|
111
|
-
query.from,
|
|
112
|
-
Target.Table(that.data()),
|
|
113
|
-
"inner",
|
|
114
|
-
Expr.and(...on).expr
|
|
115
|
-
)
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
select(selection) {
|
|
119
|
-
return new SelectMultiple({
|
|
120
|
-
...this.query(),
|
|
121
|
-
selection: ExprData.create(selection)
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
count() {
|
|
125
|
-
return new SelectSingle({
|
|
126
|
-
...this.query(),
|
|
127
|
-
selection: Functions.count().expr,
|
|
128
|
-
singleResult: true
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
orderBy(...orderBy) {
|
|
132
|
-
return new SelectMultiple({
|
|
133
|
-
...this.query(),
|
|
134
|
-
orderBy
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
groupBy(...groupBy) {
|
|
138
|
-
return new SelectMultiple({
|
|
139
|
-
...this.query(),
|
|
140
|
-
groupBy: groupBy.map(ExprData.create)
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
first() {
|
|
144
|
-
return new SelectSingle({ ...this.query(), singleResult: true });
|
|
145
|
-
}
|
|
146
|
-
where(...where) {
|
|
147
|
-
return new SelectMultiple(super.where(...where).query());
|
|
148
|
-
}
|
|
149
|
-
toExpr() {
|
|
150
|
-
return new Expr(ExprData.Query(this.query()));
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
Cursor2.SelectMultiple = SelectMultiple;
|
|
154
|
-
class SelectSingle extends Filterable {
|
|
155
|
-
query() {
|
|
156
|
-
return super.query();
|
|
157
|
-
}
|
|
158
|
-
leftJoin(that, ...on) {
|
|
159
|
-
const query = this.query();
|
|
160
|
-
return new SelectSingle({
|
|
161
|
-
...query,
|
|
162
|
-
from: Target.Join(
|
|
163
|
-
query.from,
|
|
164
|
-
Target.Table(that.data()),
|
|
165
|
-
"left",
|
|
166
|
-
Expr.and(...on).expr
|
|
167
|
-
)
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
innerJoin(that, ...on) {
|
|
171
|
-
const query = this.query();
|
|
172
|
-
return new SelectSingle({
|
|
173
|
-
...query,
|
|
174
|
-
from: Target.Join(
|
|
175
|
-
query.from,
|
|
176
|
-
Target.Table(that.data()),
|
|
177
|
-
"inner",
|
|
178
|
-
Expr.and(...on).expr
|
|
179
|
-
)
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
select(selection) {
|
|
183
|
-
return new SelectSingle({
|
|
184
|
-
...this.query(),
|
|
185
|
-
selection: ExprData.create(selection)
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
orderBy(...orderBy) {
|
|
189
|
-
return new SelectSingle({
|
|
190
|
-
...this.query(),
|
|
191
|
-
orderBy
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
groupBy(...groupBy) {
|
|
195
|
-
return new SelectSingle({
|
|
196
|
-
...this.query(),
|
|
197
|
-
groupBy: groupBy.map(ExprData.create)
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
where(...where) {
|
|
201
|
-
return new SelectSingle(super.where(...where).query());
|
|
202
|
-
}
|
|
203
|
-
toExpr() {
|
|
204
|
-
return new Expr(ExprData.Query(this.query()));
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
Cursor2.SelectSingle = SelectSingle;
|
|
208
|
-
})(Cursor || (Cursor = {}));
|
|
209
|
-
export {
|
|
210
|
-
Cursor
|
|
211
|
-
};
|
package/dist/Driver.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Cursor } from './Cursor';
|
|
2
|
-
import { Formatter } from './Formatter';
|
|
3
|
-
import { Query } from './Query';
|
|
4
|
-
import { Schema } from './Schema';
|
|
5
|
-
import { Statement } from './Statement';
|
|
6
|
-
declare class Callable extends Function {
|
|
7
|
-
constructor(fn: Function);
|
|
8
|
-
}
|
|
9
|
-
declare abstract class DriverBase extends Callable {
|
|
10
|
-
formatter: Formatter;
|
|
11
|
-
constructor(formatter: Formatter);
|
|
12
|
-
all(strings: TemplateStringsArray, ...params: Array<any>): any;
|
|
13
|
-
get(strings: TemplateStringsArray, ...params: Array<any>): any;
|
|
14
|
-
executeTemplate(expectedReturn: Query.RawReturn, strings: TemplateStringsArray, ...params: Array<any>): any;
|
|
15
|
-
abstract executeQuery(query: Query<any>): any;
|
|
16
|
-
}
|
|
17
|
-
export declare namespace Driver {
|
|
18
|
-
export interface Sync {
|
|
19
|
-
<T>(query: Cursor<T>): T;
|
|
20
|
-
(strings: TemplateStringsArray, ...values: any[]): any;
|
|
21
|
-
}
|
|
22
|
-
export abstract class Sync 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 schema(tableName: string): Schema;
|
|
31
|
-
executeQuery<T>(query: Query<T>): T;
|
|
32
|
-
all<T>(strings: TemplateStringsArray, ...params: Array<any>): Array<T>;
|
|
33
|
-
get<T>(strings: TemplateStringsArray, ...params: Array<any>): T;
|
|
34
|
-
transaction<T>(run: (query: Sync) => T): T;
|
|
35
|
-
toAsync(): SyncWrapper;
|
|
36
|
-
}
|
|
37
|
-
export interface Async {
|
|
38
|
-
<T>(query: Cursor<T>): Promise<T>;
|
|
39
|
-
(strings: TemplateStringsArray, ...values: any[]): Promise<any>;
|
|
40
|
-
}
|
|
41
|
-
export abstract class Async extends DriverBase {
|
|
42
|
-
transactionId: number;
|
|
43
|
-
abstract isolate(): [connection: Async, release: () => Promise<void>];
|
|
44
|
-
abstract rows(stmt: Statement.Compiled): Promise<Array<object>>;
|
|
45
|
-
abstract values(stmt: Statement.Compiled): Promise<Array<Array<any>>>;
|
|
46
|
-
abstract execute(stmt: Statement.Compiled): Promise<void>;
|
|
47
|
-
abstract mutate(stmt: Statement.Compiled): Promise<{
|
|
48
|
-
rowsAffected: number;
|
|
49
|
-
}>;
|
|
50
|
-
abstract schema(tableName: string): Promise<Schema>;
|
|
51
|
-
executeQuery<T>(query: Query<T>): Promise<T>;
|
|
52
|
-
all<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<Array<T>>;
|
|
53
|
-
get<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<T>;
|
|
54
|
-
transaction<T>(run: (query: Async) => T): Promise<T>;
|
|
55
|
-
}
|
|
56
|
-
class SyncWrapper extends Async {
|
|
57
|
-
private sync;
|
|
58
|
-
lock: Promise<void> | undefined;
|
|
59
|
-
constructor(sync: Sync);
|
|
60
|
-
executeQuery<T>(query: Query<T>): Promise<T>;
|
|
61
|
-
rows(stmt: Statement.Compiled): Promise<Array<object>>;
|
|
62
|
-
values(stmt: Statement.Compiled): Promise<Array<Array<any>>>;
|
|
63
|
-
execute(stmt: Statement.Compiled): Promise<void>;
|
|
64
|
-
mutate(stmt: Statement.Compiled): Promise<{
|
|
65
|
-
rowsAffected: number;
|
|
66
|
-
}>;
|
|
67
|
-
schema(tableName: string): Promise<Schema>;
|
|
68
|
-
isolate(): [connection: Async, release: () => Promise<void>];
|
|
69
|
-
}
|
|
70
|
-
export {};
|
|
71
|
-
}
|
|
72
|
-
export {};
|