@devbro/neko-sql 0.1.0
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 +30 -0
- package/dist/Blueprint.d.mts +39 -0
- package/dist/Blueprint.d.ts +39 -0
- package/dist/Blueprint.js +127 -0
- package/dist/Blueprint.js.map +1 -0
- package/dist/Blueprint.mjs +102 -0
- package/dist/Blueprint.mjs.map +1 -0
- package/dist/Connection-DBxWn3YO.d.ts +101 -0
- package/dist/Connection-Z5qLWvdu.d.mts +101 -0
- package/dist/Connection.d.mts +4 -0
- package/dist/Connection.d.ts +4 -0
- package/dist/Connection.js +30 -0
- package/dist/Connection.js.map +1 -0
- package/dist/Connection.mjs +6 -0
- package/dist/Connection.mjs.map +1 -0
- package/dist/Expression.d.mts +1 -0
- package/dist/Expression.d.ts +1 -0
- package/dist/Expression.js +37 -0
- package/dist/Expression.js.map +1 -0
- package/dist/Expression.mjs +13 -0
- package/dist/Expression.mjs.map +1 -0
- package/dist/Migration.d.mts +11 -0
- package/dist/Migration.d.ts +11 -0
- package/dist/Migration.js +30 -0
- package/dist/Migration.js.map +1 -0
- package/dist/Migration.mjs +6 -0
- package/dist/Migration.mjs.map +1 -0
- package/dist/Query.d.mts +4 -0
- package/dist/Query.d.ts +4 -0
- package/dist/Query.js +163 -0
- package/dist/Query.js.map +1 -0
- package/dist/Query.mjs +139 -0
- package/dist/Query.mjs.map +1 -0
- package/dist/QueryGrammar.d.mts +4 -0
- package/dist/QueryGrammar.d.ts +4 -0
- package/dist/QueryGrammar.js +241 -0
- package/dist/QueryGrammar.js.map +1 -0
- package/dist/QueryGrammar.mjs +217 -0
- package/dist/QueryGrammar.mjs.map +1 -0
- package/dist/Schema.d.mts +4 -0
- package/dist/Schema.d.ts +4 -0
- package/dist/Schema.js +62 -0
- package/dist/Schema.js.map +1 -0
- package/dist/Schema.mjs +38 -0
- package/dist/Schema.mjs.map +1 -0
- package/dist/SchemaGrammar.d.mts +17 -0
- package/dist/SchemaGrammar.d.ts +17 -0
- package/dist/SchemaGrammar.js +138 -0
- package/dist/SchemaGrammar.js.map +1 -0
- package/dist/SchemaGrammar.mjs +114 -0
- package/dist/SchemaGrammar.mjs.map +1 -0
- package/dist/databases/index.d.mts +8 -0
- package/dist/databases/index.d.ts +8 -0
- package/dist/databases/index.js +23 -0
- package/dist/databases/index.js.map +1 -0
- package/dist/databases/index.mjs +2 -0
- package/dist/databases/index.mjs.map +1 -0
- package/dist/databases/postgresql/PostgresqlConnection.d.mts +24 -0
- package/dist/databases/postgresql/PostgresqlConnection.d.ts +24 -0
- package/dist/databases/postgresql/PostgresqlConnection.js +108 -0
- package/dist/databases/postgresql/PostgresqlConnection.js.map +1 -0
- package/dist/databases/postgresql/PostgresqlConnection.mjs +74 -0
- package/dist/databases/postgresql/PostgresqlConnection.mjs.map +1 -0
- package/dist/databases/postgresql/PostgresqlQueryGrammar.d.mts +20 -0
- package/dist/databases/postgresql/PostgresqlQueryGrammar.d.ts +20 -0
- package/dist/databases/postgresql/PostgresqlQueryGrammar.js +65 -0
- package/dist/databases/postgresql/PostgresqlQueryGrammar.js.map +1 -0
- package/dist/databases/postgresql/PostgresqlQueryGrammar.mjs +41 -0
- package/dist/databases/postgresql/PostgresqlQueryGrammar.mjs.map +1 -0
- package/dist/databases/postgresql/PostgresqlSchemaGrammar.d.mts +8 -0
- package/dist/databases/postgresql/PostgresqlSchemaGrammar.d.ts +8 -0
- package/dist/databases/postgresql/PostgresqlSchemaGrammar.js +31 -0
- package/dist/databases/postgresql/PostgresqlSchemaGrammar.js.map +1 -0
- package/dist/databases/postgresql/PostgresqlSchemaGrammar.mjs +7 -0
- package/dist/databases/postgresql/PostgresqlSchemaGrammar.mjs.map +1 -0
- package/dist/databases/postgresql/index.d.mts +8 -0
- package/dist/databases/postgresql/index.d.ts +8 -0
- package/dist/databases/postgresql/index.js +27 -0
- package/dist/databases/postgresql/index.js.map +1 -0
- package/dist/databases/postgresql/index.mjs +4 -0
- package/dist/databases/postgresql/index.mjs.map +1 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +9 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types-C_aDrXJN.d.mts +48 -0
- package/dist/types-C_aDrXJN.d.ts +48 -0
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +1 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +70 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @devbro/neko-sql
|
|
2
|
+
|
|
3
|
+
SQL engine for quick abstracted relational database connections.
|
|
4
|
+
|
|
5
|
+
## supported features
|
|
6
|
+
|
|
7
|
+
- data manipulation(select, insert, update, delete)
|
|
8
|
+
- schema manipulation(create table, alter table, ...)
|
|
9
|
+
- transactions
|
|
10
|
+
- joins
|
|
11
|
+
|
|
12
|
+
## Suported Databases
|
|
13
|
+
|
|
14
|
+
currently supported databases:
|
|
15
|
+
|
|
16
|
+
- postgresql
|
|
17
|
+
|
|
18
|
+
future planned:
|
|
19
|
+
|
|
20
|
+
- mysql
|
|
21
|
+
- sqlite
|
|
22
|
+
- mssql
|
|
23
|
+
|
|
24
|
+
## how to use
|
|
25
|
+
|
|
26
|
+
please check test classes for reboust examples
|
|
27
|
+
|
|
28
|
+
## APIs
|
|
29
|
+
|
|
30
|
+
-- TODO: add all available methods and how to use them
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { P as Parameter } from './types-C_aDrXJN.mjs';
|
|
2
|
+
|
|
3
|
+
type ColumnPropertiesType = {
|
|
4
|
+
type: 'string' | 'integer' | 'float' | 'double' | 'boolean' | 'char' | 'text' | 'date' | 'timestamp' | 'serial';
|
|
5
|
+
length: number;
|
|
6
|
+
nullable: boolean;
|
|
7
|
+
unique: boolean;
|
|
8
|
+
default: Parameter;
|
|
9
|
+
};
|
|
10
|
+
declare class Column {
|
|
11
|
+
columnName: string;
|
|
12
|
+
properties: ColumnPropertiesType;
|
|
13
|
+
constructor(columnName: string, type: ColumnPropertiesType['type']);
|
|
14
|
+
length(length: number): this;
|
|
15
|
+
nullable(nullable?: boolean): this;
|
|
16
|
+
unique(unique?: boolean): this;
|
|
17
|
+
default(value: ColumnPropertiesType['default']): this;
|
|
18
|
+
}
|
|
19
|
+
declare class Blueprint {
|
|
20
|
+
tableName: string;
|
|
21
|
+
columns: Column[];
|
|
22
|
+
existingTable: boolean;
|
|
23
|
+
primaryKeys: string[];
|
|
24
|
+
constructor();
|
|
25
|
+
setTableName(tableName: string, existingTable?: boolean): void;
|
|
26
|
+
Boolean(columnName: string): Column;
|
|
27
|
+
char(columnName: string): Column;
|
|
28
|
+
string(columnName: string, length?: number): Column;
|
|
29
|
+
text(columnName: string): Column;
|
|
30
|
+
integer(columnName: string): Column;
|
|
31
|
+
float(columnName: string): Column;
|
|
32
|
+
double(columnName: string): Column;
|
|
33
|
+
id(): Column;
|
|
34
|
+
timestamps(): void;
|
|
35
|
+
date(columnName: string): Column;
|
|
36
|
+
primary(keys: string[]): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { Blueprint, Column, type ColumnPropertiesType };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { P as Parameter } from './types-C_aDrXJN.js';
|
|
2
|
+
|
|
3
|
+
type ColumnPropertiesType = {
|
|
4
|
+
type: 'string' | 'integer' | 'float' | 'double' | 'boolean' | 'char' | 'text' | 'date' | 'timestamp' | 'serial';
|
|
5
|
+
length: number;
|
|
6
|
+
nullable: boolean;
|
|
7
|
+
unique: boolean;
|
|
8
|
+
default: Parameter;
|
|
9
|
+
};
|
|
10
|
+
declare class Column {
|
|
11
|
+
columnName: string;
|
|
12
|
+
properties: ColumnPropertiesType;
|
|
13
|
+
constructor(columnName: string, type: ColumnPropertiesType['type']);
|
|
14
|
+
length(length: number): this;
|
|
15
|
+
nullable(nullable?: boolean): this;
|
|
16
|
+
unique(unique?: boolean): this;
|
|
17
|
+
default(value: ColumnPropertiesType['default']): this;
|
|
18
|
+
}
|
|
19
|
+
declare class Blueprint {
|
|
20
|
+
tableName: string;
|
|
21
|
+
columns: Column[];
|
|
22
|
+
existingTable: boolean;
|
|
23
|
+
primaryKeys: string[];
|
|
24
|
+
constructor();
|
|
25
|
+
setTableName(tableName: string, existingTable?: boolean): void;
|
|
26
|
+
Boolean(columnName: string): Column;
|
|
27
|
+
char(columnName: string): Column;
|
|
28
|
+
string(columnName: string, length?: number): Column;
|
|
29
|
+
text(columnName: string): Column;
|
|
30
|
+
integer(columnName: string): Column;
|
|
31
|
+
float(columnName: string): Column;
|
|
32
|
+
double(columnName: string): Column;
|
|
33
|
+
id(): Column;
|
|
34
|
+
timestamps(): void;
|
|
35
|
+
date(columnName: string): Column;
|
|
36
|
+
primary(keys: string[]): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { Blueprint, Column, type ColumnPropertiesType };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Blueprint_exports = {};
|
|
20
|
+
__export(Blueprint_exports, {
|
|
21
|
+
Blueprint: () => Blueprint,
|
|
22
|
+
Column: () => Column
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Blueprint_exports);
|
|
25
|
+
var import_Expression = require("./Expression");
|
|
26
|
+
class Column {
|
|
27
|
+
columnName = "";
|
|
28
|
+
properties = {
|
|
29
|
+
type: "string",
|
|
30
|
+
length: 255,
|
|
31
|
+
nullable: false,
|
|
32
|
+
unique: false,
|
|
33
|
+
default: null
|
|
34
|
+
};
|
|
35
|
+
constructor(columnName, type) {
|
|
36
|
+
this.columnName = columnName;
|
|
37
|
+
this.properties.type = type;
|
|
38
|
+
}
|
|
39
|
+
length(length) {
|
|
40
|
+
this.properties.length = length;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
nullable(nullable = true) {
|
|
44
|
+
this.properties.nullable = nullable;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
unique(unique = true) {
|
|
48
|
+
this.properties.unique = unique;
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
default(value) {
|
|
52
|
+
this.properties.default = value;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class Blueprint {
|
|
57
|
+
tableName = "";
|
|
58
|
+
columns = [];
|
|
59
|
+
existingTable = false;
|
|
60
|
+
primaryKeys = [];
|
|
61
|
+
constructor() {
|
|
62
|
+
}
|
|
63
|
+
setTableName(tableName, existingTable = false) {
|
|
64
|
+
this.tableName = tableName;
|
|
65
|
+
this.existingTable = existingTable;
|
|
66
|
+
}
|
|
67
|
+
Boolean(columnName) {
|
|
68
|
+
const rc = new Column(columnName, "boolean");
|
|
69
|
+
this.columns.push(rc);
|
|
70
|
+
return rc;
|
|
71
|
+
}
|
|
72
|
+
char(columnName) {
|
|
73
|
+
const rc = new Column(columnName, "char");
|
|
74
|
+
this.columns.push(rc);
|
|
75
|
+
return rc;
|
|
76
|
+
}
|
|
77
|
+
string(columnName, length = 255) {
|
|
78
|
+
const rc = new Column(columnName, "string");
|
|
79
|
+
rc.length(length);
|
|
80
|
+
this.columns.push(rc);
|
|
81
|
+
return rc;
|
|
82
|
+
}
|
|
83
|
+
text(columnName) {
|
|
84
|
+
const rc = new Column(columnName, "text");
|
|
85
|
+
this.columns.push(rc);
|
|
86
|
+
return rc;
|
|
87
|
+
}
|
|
88
|
+
integer(columnName) {
|
|
89
|
+
const rc = new Column(columnName, "integer");
|
|
90
|
+
this.columns.push(rc);
|
|
91
|
+
return rc;
|
|
92
|
+
}
|
|
93
|
+
float(columnName) {
|
|
94
|
+
const rc = new Column(columnName, "float");
|
|
95
|
+
this.columns.push(rc);
|
|
96
|
+
return rc;
|
|
97
|
+
}
|
|
98
|
+
double(columnName) {
|
|
99
|
+
const rc = new Column(columnName, "double");
|
|
100
|
+
this.columns.push(rc);
|
|
101
|
+
return rc;
|
|
102
|
+
}
|
|
103
|
+
id() {
|
|
104
|
+
const rc = new Column("id", "serial");
|
|
105
|
+
this.columns.push(rc);
|
|
106
|
+
this.primaryKeys.push("id");
|
|
107
|
+
return rc;
|
|
108
|
+
}
|
|
109
|
+
timestamps() {
|
|
110
|
+
this.columns.push(new Column("created_at", "timestamp").default(new import_Expression.Expression("CURRENT_TIMESTAMP")));
|
|
111
|
+
this.columns.push(new Column("updated_at", "timestamp").default(new import_Expression.Expression("CURRENT_TIMESTAMP")));
|
|
112
|
+
}
|
|
113
|
+
date(columnName) {
|
|
114
|
+
const rc = new Column(columnName, "date");
|
|
115
|
+
this.columns.push(rc);
|
|
116
|
+
return rc;
|
|
117
|
+
}
|
|
118
|
+
primary(keys) {
|
|
119
|
+
this.primaryKeys = keys;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {
|
|
124
|
+
Blueprint,
|
|
125
|
+
Column
|
|
126
|
+
});
|
|
127
|
+
//# sourceMappingURL=Blueprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Blueprint.ts"],"sourcesContent":["import { Expression } from './Expression';\nimport { Parameter } from './types';\n\nexport type ColumnPropertiesType = {\n type:\n | 'string'\n | 'integer'\n | 'float'\n | 'double'\n | 'boolean'\n | 'char'\n | 'text'\n | 'date'\n | 'timestamp'\n | 'serial';\n length: number;\n nullable: boolean;\n unique: boolean;\n default: Parameter;\n};\nexport class Column {\n columnName: string = '';\n properties: ColumnPropertiesType = {\n type: 'string',\n length: 255,\n nullable: false,\n unique: false,\n default: null,\n };\n\n constructor(columnName: string, type: ColumnPropertiesType['type']) {\n this.columnName = columnName;\n this.properties.type = type;\n }\n\n length(length: number) {\n this.properties.length = length;\n return this;\n }\n\n nullable(nullable: boolean = true) {\n this.properties.nullable = nullable;\n return this;\n }\n\n unique(unique: boolean = true) {\n this.properties.unique = unique;\n return this;\n }\n\n default(value: ColumnPropertiesType['default']) {\n this.properties.default = value;\n return this;\n }\n}\nexport class Blueprint {\n tableName: string = '';\n columns: Column[] = [];\n existingTable: boolean = false;\n primaryKeys: string[] = [];\n constructor() {}\n setTableName(tableName: string, existingTable: boolean = false) {\n this.tableName = tableName;\n this.existingTable = existingTable;\n }\n\n Boolean(columnName: string) {\n const rc = new Column(columnName, 'boolean');\n this.columns.push(rc);\n return rc;\n }\n\n char(columnName: string) {\n const rc = new Column(columnName, 'char');\n this.columns.push(rc);\n return rc;\n }\n\n string(columnName: string, length: number = 255) {\n const rc = new Column(columnName, 'string');\n rc.length(length);\n this.columns.push(rc);\n return rc;\n }\n\n text(columnName: string) {\n const rc = new Column(columnName, 'text');\n this.columns.push(rc);\n return rc;\n }\n\n integer(columnName: string) {\n const rc = new Column(columnName, 'integer');\n this.columns.push(rc);\n return rc;\n }\n\n float(columnName: string) {\n const rc = new Column(columnName, 'float');\n this.columns.push(rc);\n return rc;\n }\n\n double(columnName: string) {\n const rc = new Column(columnName, 'double');\n this.columns.push(rc);\n return rc;\n }\n\n id() {\n const rc = new Column('id', 'serial');\n this.columns.push(rc);\n this.primaryKeys.push('id');\n return rc;\n }\n\n timestamps() {\n this.columns.push(new Column('created_at', 'timestamp').default(new Expression('CURRENT_TIMESTAMP')));\n this.columns.push(new Column('updated_at', 'timestamp').default(new Expression('CURRENT_TIMESTAMP')));\n }\n\n date(columnName: string) {\n const rc = new Column(columnName, 'date');\n this.columns.push(rc);\n return rc;\n }\n\n primary(keys: string[]) {\n this.primaryKeys = keys;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA2B;AAoBpB,MAAM,OAAO;AAAA,EAClB,aAAqB;AAAA,EACrB,aAAmC;AAAA,IACjC,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EAEA,YAAY,YAAoB,MAAoC;AAClE,SAAK,aAAa;AAClB,SAAK,WAAW,OAAO;AAAA,EACzB;AAAA,EAEA,OAAO,QAAgB;AACrB,SAAK,WAAW,SAAS;AACzB,WAAO;AAAA,EACT;AAAA,EAEA,SAAS,WAAoB,MAAM;AACjC,SAAK,WAAW,WAAW;AAC3B,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,SAAkB,MAAM;AAC7B,SAAK,WAAW,SAAS;AACzB,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,OAAwC;AAC9C,SAAK,WAAW,UAAU;AAC1B,WAAO;AAAA,EACT;AACF;AACO,MAAM,UAAU;AAAA,EACrB,YAAoB;AAAA,EACpB,UAAoB,CAAC;AAAA,EACrB,gBAAyB;AAAA,EACzB,cAAwB,CAAC;AAAA,EACzB,cAAc;AAAA,EAAC;AAAA,EACf,aAAa,WAAmB,gBAAyB,OAAO;AAC9D,SAAK,YAAY;AACjB,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,QAAQ,YAAoB;AAC1B,UAAM,KAAK,IAAI,OAAO,YAAY,SAAS;AAC3C,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,KAAK,YAAoB;AACvB,UAAM,KAAK,IAAI,OAAO,YAAY,MAAM;AACxC,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,YAAoB,SAAiB,KAAK;AAC/C,UAAM,KAAK,IAAI,OAAO,YAAY,QAAQ;AAC1C,OAAG,OAAO,MAAM;AAChB,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,KAAK,YAAoB;AACvB,UAAM,KAAK,IAAI,OAAO,YAAY,MAAM;AACxC,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,YAAoB;AAC1B,UAAM,KAAK,IAAI,OAAO,YAAY,SAAS;AAC3C,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,YAAoB;AACxB,UAAM,KAAK,IAAI,OAAO,YAAY,OAAO;AACzC,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,YAAoB;AACzB,UAAM,KAAK,IAAI,OAAO,YAAY,QAAQ;AAC1C,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,KAAK;AACH,UAAM,KAAK,IAAI,OAAO,MAAM,QAAQ;AACpC,SAAK,QAAQ,KAAK,EAAE;AACpB,SAAK,YAAY,KAAK,IAAI;AAC1B,WAAO;AAAA,EACT;AAAA,EAEA,aAAa;AACX,SAAK,QAAQ,KAAK,IAAI,OAAO,cAAc,WAAW,EAAE,QAAQ,IAAI,6BAAW,mBAAmB,CAAC,CAAC;AACpG,SAAK,QAAQ,KAAK,IAAI,OAAO,cAAc,WAAW,EAAE,QAAQ,IAAI,6BAAW,mBAAmB,CAAC,CAAC;AAAA,EACtG;AAAA,EAEA,KAAK,YAAoB;AACvB,UAAM,KAAK,IAAI,OAAO,YAAY,MAAM;AACxC,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,MAAgB;AACtB,SAAK,cAAc;AAAA,EACrB;AACF;","names":[]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Expression } from "./Expression";
|
|
2
|
+
class Column {
|
|
3
|
+
columnName = "";
|
|
4
|
+
properties = {
|
|
5
|
+
type: "string",
|
|
6
|
+
length: 255,
|
|
7
|
+
nullable: false,
|
|
8
|
+
unique: false,
|
|
9
|
+
default: null
|
|
10
|
+
};
|
|
11
|
+
constructor(columnName, type) {
|
|
12
|
+
this.columnName = columnName;
|
|
13
|
+
this.properties.type = type;
|
|
14
|
+
}
|
|
15
|
+
length(length) {
|
|
16
|
+
this.properties.length = length;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
nullable(nullable = true) {
|
|
20
|
+
this.properties.nullable = nullable;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
unique(unique = true) {
|
|
24
|
+
this.properties.unique = unique;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
default(value) {
|
|
28
|
+
this.properties.default = value;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class Blueprint {
|
|
33
|
+
tableName = "";
|
|
34
|
+
columns = [];
|
|
35
|
+
existingTable = false;
|
|
36
|
+
primaryKeys = [];
|
|
37
|
+
constructor() {
|
|
38
|
+
}
|
|
39
|
+
setTableName(tableName, existingTable = false) {
|
|
40
|
+
this.tableName = tableName;
|
|
41
|
+
this.existingTable = existingTable;
|
|
42
|
+
}
|
|
43
|
+
Boolean(columnName) {
|
|
44
|
+
const rc = new Column(columnName, "boolean");
|
|
45
|
+
this.columns.push(rc);
|
|
46
|
+
return rc;
|
|
47
|
+
}
|
|
48
|
+
char(columnName) {
|
|
49
|
+
const rc = new Column(columnName, "char");
|
|
50
|
+
this.columns.push(rc);
|
|
51
|
+
return rc;
|
|
52
|
+
}
|
|
53
|
+
string(columnName, length = 255) {
|
|
54
|
+
const rc = new Column(columnName, "string");
|
|
55
|
+
rc.length(length);
|
|
56
|
+
this.columns.push(rc);
|
|
57
|
+
return rc;
|
|
58
|
+
}
|
|
59
|
+
text(columnName) {
|
|
60
|
+
const rc = new Column(columnName, "text");
|
|
61
|
+
this.columns.push(rc);
|
|
62
|
+
return rc;
|
|
63
|
+
}
|
|
64
|
+
integer(columnName) {
|
|
65
|
+
const rc = new Column(columnName, "integer");
|
|
66
|
+
this.columns.push(rc);
|
|
67
|
+
return rc;
|
|
68
|
+
}
|
|
69
|
+
float(columnName) {
|
|
70
|
+
const rc = new Column(columnName, "float");
|
|
71
|
+
this.columns.push(rc);
|
|
72
|
+
return rc;
|
|
73
|
+
}
|
|
74
|
+
double(columnName) {
|
|
75
|
+
const rc = new Column(columnName, "double");
|
|
76
|
+
this.columns.push(rc);
|
|
77
|
+
return rc;
|
|
78
|
+
}
|
|
79
|
+
id() {
|
|
80
|
+
const rc = new Column("id", "serial");
|
|
81
|
+
this.columns.push(rc);
|
|
82
|
+
this.primaryKeys.push("id");
|
|
83
|
+
return rc;
|
|
84
|
+
}
|
|
85
|
+
timestamps() {
|
|
86
|
+
this.columns.push(new Column("created_at", "timestamp").default(new Expression("CURRENT_TIMESTAMP")));
|
|
87
|
+
this.columns.push(new Column("updated_at", "timestamp").default(new Expression("CURRENT_TIMESTAMP")));
|
|
88
|
+
}
|
|
89
|
+
date(columnName) {
|
|
90
|
+
const rc = new Column(columnName, "date");
|
|
91
|
+
this.columns.push(rc);
|
|
92
|
+
return rc;
|
|
93
|
+
}
|
|
94
|
+
primary(keys) {
|
|
95
|
+
this.primaryKeys = keys;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
Blueprint,
|
|
100
|
+
Column
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=Blueprint.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Blueprint.ts"],"sourcesContent":["import { Expression } from './Expression';\nimport { Parameter } from './types';\n\nexport type ColumnPropertiesType = {\n type:\n | 'string'\n | 'integer'\n | 'float'\n | 'double'\n | 'boolean'\n | 'char'\n | 'text'\n | 'date'\n | 'timestamp'\n | 'serial';\n length: number;\n nullable: boolean;\n unique: boolean;\n default: Parameter;\n};\nexport class Column {\n columnName: string = '';\n properties: ColumnPropertiesType = {\n type: 'string',\n length: 255,\n nullable: false,\n unique: false,\n default: null,\n };\n\n constructor(columnName: string, type: ColumnPropertiesType['type']) {\n this.columnName = columnName;\n this.properties.type = type;\n }\n\n length(length: number) {\n this.properties.length = length;\n return this;\n }\n\n nullable(nullable: boolean = true) {\n this.properties.nullable = nullable;\n return this;\n }\n\n unique(unique: boolean = true) {\n this.properties.unique = unique;\n return this;\n }\n\n default(value: ColumnPropertiesType['default']) {\n this.properties.default = value;\n return this;\n }\n}\nexport class Blueprint {\n tableName: string = '';\n columns: Column[] = [];\n existingTable: boolean = false;\n primaryKeys: string[] = [];\n constructor() {}\n setTableName(tableName: string, existingTable: boolean = false) {\n this.tableName = tableName;\n this.existingTable = existingTable;\n }\n\n Boolean(columnName: string) {\n const rc = new Column(columnName, 'boolean');\n this.columns.push(rc);\n return rc;\n }\n\n char(columnName: string) {\n const rc = new Column(columnName, 'char');\n this.columns.push(rc);\n return rc;\n }\n\n string(columnName: string, length: number = 255) {\n const rc = new Column(columnName, 'string');\n rc.length(length);\n this.columns.push(rc);\n return rc;\n }\n\n text(columnName: string) {\n const rc = new Column(columnName, 'text');\n this.columns.push(rc);\n return rc;\n }\n\n integer(columnName: string) {\n const rc = new Column(columnName, 'integer');\n this.columns.push(rc);\n return rc;\n }\n\n float(columnName: string) {\n const rc = new Column(columnName, 'float');\n this.columns.push(rc);\n return rc;\n }\n\n double(columnName: string) {\n const rc = new Column(columnName, 'double');\n this.columns.push(rc);\n return rc;\n }\n\n id() {\n const rc = new Column('id', 'serial');\n this.columns.push(rc);\n this.primaryKeys.push('id');\n return rc;\n }\n\n timestamps() {\n this.columns.push(new Column('created_at', 'timestamp').default(new Expression('CURRENT_TIMESTAMP')));\n this.columns.push(new Column('updated_at', 'timestamp').default(new Expression('CURRENT_TIMESTAMP')));\n }\n\n date(columnName: string) {\n const rc = new Column(columnName, 'date');\n this.columns.push(rc);\n return rc;\n }\n\n primary(keys: string[]) {\n this.primaryKeys = keys;\n }\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAoBpB,MAAM,OAAO;AAAA,EAClB,aAAqB;AAAA,EACrB,aAAmC;AAAA,IACjC,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EAEA,YAAY,YAAoB,MAAoC;AAClE,SAAK,aAAa;AAClB,SAAK,WAAW,OAAO;AAAA,EACzB;AAAA,EAEA,OAAO,QAAgB;AACrB,SAAK,WAAW,SAAS;AACzB,WAAO;AAAA,EACT;AAAA,EAEA,SAAS,WAAoB,MAAM;AACjC,SAAK,WAAW,WAAW;AAC3B,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,SAAkB,MAAM;AAC7B,SAAK,WAAW,SAAS;AACzB,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,OAAwC;AAC9C,SAAK,WAAW,UAAU;AAC1B,WAAO;AAAA,EACT;AACF;AACO,MAAM,UAAU;AAAA,EACrB,YAAoB;AAAA,EACpB,UAAoB,CAAC;AAAA,EACrB,gBAAyB;AAAA,EACzB,cAAwB,CAAC;AAAA,EACzB,cAAc;AAAA,EAAC;AAAA,EACf,aAAa,WAAmB,gBAAyB,OAAO;AAC9D,SAAK,YAAY;AACjB,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,QAAQ,YAAoB;AAC1B,UAAM,KAAK,IAAI,OAAO,YAAY,SAAS;AAC3C,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,KAAK,YAAoB;AACvB,UAAM,KAAK,IAAI,OAAO,YAAY,MAAM;AACxC,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,YAAoB,SAAiB,KAAK;AAC/C,UAAM,KAAK,IAAI,OAAO,YAAY,QAAQ;AAC1C,OAAG,OAAO,MAAM;AAChB,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,KAAK,YAAoB;AACvB,UAAM,KAAK,IAAI,OAAO,YAAY,MAAM;AACxC,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,YAAoB;AAC1B,UAAM,KAAK,IAAI,OAAO,YAAY,SAAS;AAC3C,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,YAAoB;AACxB,UAAM,KAAK,IAAI,OAAO,YAAY,OAAO;AACzC,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,YAAoB;AACzB,UAAM,KAAK,IAAI,OAAO,YAAY,QAAQ;AAC1C,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,KAAK;AACH,UAAM,KAAK,IAAI,OAAO,MAAM,QAAQ;AACpC,SAAK,QAAQ,KAAK,EAAE;AACpB,SAAK,YAAY,KAAK,IAAI;AAC1B,WAAO;AAAA,EACT;AAAA,EAEA,aAAa;AACX,SAAK,QAAQ,KAAK,IAAI,OAAO,cAAc,WAAW,EAAE,QAAQ,IAAI,WAAW,mBAAmB,CAAC,CAAC;AACpG,SAAK,QAAQ,KAAK,IAAI,OAAO,cAAc,WAAW,EAAE,QAAQ,IAAI,WAAW,mBAAmB,CAAC,CAAC;AAAA,EACtG;AAAA,EAEA,KAAK,YAAoB;AACvB,UAAM,KAAK,IAAI,OAAO,YAAY,MAAM;AACxC,SAAK,QAAQ,KAAK,EAAE;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,MAAgB;AACtB,SAAK,cAAc;AAAA,EACrB;AACF;","names":[]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Blueprint } from './Blueprint.js';
|
|
2
|
+
import { C as CompiledSql, s as selectType, j as joinType, e as whereType, a as whereOp, b as whereOpColumn, d as whereNull, P as Parameter, h as havingType, c as whereRaw, J as JoinCondition } from './types-C_aDrXJN.js';
|
|
3
|
+
import { SchemaGrammar } from './SchemaGrammar.js';
|
|
4
|
+
|
|
5
|
+
declare class Schema {
|
|
6
|
+
private readonly connection;
|
|
7
|
+
private readonly grammar;
|
|
8
|
+
constructor(connection: Connection | null, grammar: SchemaGrammar);
|
|
9
|
+
createTable(tableName: string, structMethod: (blueprint: Blueprint) => void): Promise<void>;
|
|
10
|
+
dropTable(tableName: string): Promise<void>;
|
|
11
|
+
tables(): Promise<any>;
|
|
12
|
+
tableExists(table_name: string): Promise<boolean>;
|
|
13
|
+
dropTableIfExists(tableName: string): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare abstract class QueryGrammar {
|
|
17
|
+
sqlParts: string[];
|
|
18
|
+
toSql(query: Query): CompiledSql;
|
|
19
|
+
compileSelect(selects: selectType[]): CompiledSql;
|
|
20
|
+
compileTable(tableName: string): CompiledSql;
|
|
21
|
+
compileJoin(joins: joinType[]): CompiledSql;
|
|
22
|
+
compileWhere(wheres: whereType[]): CompiledSql;
|
|
23
|
+
compileWhereOperation(w: whereOp): CompiledSql;
|
|
24
|
+
compileWhereOperationColumn(w: whereOpColumn): CompiledSql;
|
|
25
|
+
compileOrderBy(orderBy: string[]): CompiledSql;
|
|
26
|
+
compileLimit(limit: number | null): CompiledSql;
|
|
27
|
+
compileOffset(offset: number | null): CompiledSql;
|
|
28
|
+
abstract getVariablePlaceholder(): string;
|
|
29
|
+
compileWhereNull(w: whereNull): CompiledSql;
|
|
30
|
+
compileInsert(query: Query, data: Record<string, Parameter>): CompiledSql;
|
|
31
|
+
abstract compileInsertGetId(query: Query, data: Record<string, Parameter>, options: {
|
|
32
|
+
primaryKey: string[];
|
|
33
|
+
}): CompiledSql;
|
|
34
|
+
compileUpdate(query: Query, data: Record<string, Parameter>): CompiledSql;
|
|
35
|
+
compileDelete(query: Query): CompiledSql;
|
|
36
|
+
compileUpsert(query: Query, data: Record<string, Parameter>, conflictFields: string[], updateFields: string[]): CompiledSql;
|
|
37
|
+
compileGroupBy(groupBy: string[]): CompiledSql;
|
|
38
|
+
compileHaving(having: havingType[]): CompiledSql;
|
|
39
|
+
compileHavingOperation(w: whereOp): CompiledSql;
|
|
40
|
+
compileHavingRaw(w: whereRaw): CompiledSql;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type QueryParts = {
|
|
44
|
+
select: selectType[];
|
|
45
|
+
table: string;
|
|
46
|
+
join: joinType[];
|
|
47
|
+
where: whereType[];
|
|
48
|
+
groupBy: string[];
|
|
49
|
+
having: havingType[];
|
|
50
|
+
orderBy: string[];
|
|
51
|
+
limit: number | null;
|
|
52
|
+
offset: number | null;
|
|
53
|
+
};
|
|
54
|
+
declare class Query {
|
|
55
|
+
private readonly connection;
|
|
56
|
+
private readonly grammar;
|
|
57
|
+
allowedOperations: string[];
|
|
58
|
+
parts: QueryParts;
|
|
59
|
+
constructor(connection: Connection | null, grammar: QueryGrammar);
|
|
60
|
+
table(tableName: string): this;
|
|
61
|
+
whereOp(column: string, operation: (typeof this.allowedOperations)[number], value: Parameter, joinCondition?: JoinCondition, negateCondition?: boolean): this;
|
|
62
|
+
whereColumn(column1: string, operation: (typeof this.allowedOperations)[number], column2: string, joinCondition?: JoinCondition, negateCondition?: boolean): this;
|
|
63
|
+
whereNull(column: string, joinCondition?: JoinCondition, negateCondition?: boolean): this;
|
|
64
|
+
clearWhere(): this;
|
|
65
|
+
select(selects: selectType[]): this;
|
|
66
|
+
groupBy(columns: string[]): this;
|
|
67
|
+
havingOp(column: string, operation: (typeof this.allowedOperations)[number], value: Parameter, joinCondition?: JoinCondition, negateCondition?: boolean): this;
|
|
68
|
+
havingRaw(sql: string, bindings: Parameter[], joinCondition?: JoinCondition, negateCondition?: boolean): this;
|
|
69
|
+
orderBy(column: string, direction?: 'asc' | 'desc'): this;
|
|
70
|
+
limit(limit: number): this;
|
|
71
|
+
offset(offset: number): this;
|
|
72
|
+
toSql(): CompiledSql;
|
|
73
|
+
get(): Promise<any>;
|
|
74
|
+
getCursor(): Promise<any>;
|
|
75
|
+
getConnection(): Connection | null;
|
|
76
|
+
insert(data: Record<string, Parameter>): Promise<any>;
|
|
77
|
+
insertGetId(data: Record<string, Parameter>, options?: {
|
|
78
|
+
primaryKey: string[];
|
|
79
|
+
}): Promise<any>;
|
|
80
|
+
update(data: Record<string, Parameter>): Promise<any>;
|
|
81
|
+
upsert(data: Record<string, Parameter>, uniqueColumns: string[], updateColumns: string[]): Promise<any>;
|
|
82
|
+
delete(): Promise<any>;
|
|
83
|
+
innerJoin(table: string, condtions: whereType[]): this;
|
|
84
|
+
leftJoin(table: string, condtions: whereType[]): this;
|
|
85
|
+
rightJoin(table: string, condtions: whereType[]): this;
|
|
86
|
+
fullJoin(table: string, condtions: whereType[]): this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
declare abstract class Connection {
|
|
90
|
+
abstract connect(): Promise<boolean>;
|
|
91
|
+
abstract runQuery(sql: CompiledSql): Promise<any>;
|
|
92
|
+
abstract runCursor(sql: CompiledSql): Promise<any>;
|
|
93
|
+
abstract disconnect(): Promise<boolean>;
|
|
94
|
+
abstract getQuery(): Query;
|
|
95
|
+
abstract getSchema(): Schema;
|
|
96
|
+
abstract beginTransaction(): Promise<void>;
|
|
97
|
+
abstract commit(): Promise<void>;
|
|
98
|
+
abstract rollback(): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { Connection as C, type QueryParts as Q, Schema as S, Query as a, QueryGrammar as b };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Blueprint } from './Blueprint.mjs';
|
|
2
|
+
import { C as CompiledSql, s as selectType, j as joinType, e as whereType, a as whereOp, b as whereOpColumn, d as whereNull, P as Parameter, h as havingType, c as whereRaw, J as JoinCondition } from './types-C_aDrXJN.mjs';
|
|
3
|
+
import { SchemaGrammar } from './SchemaGrammar.mjs';
|
|
4
|
+
|
|
5
|
+
declare class Schema {
|
|
6
|
+
private readonly connection;
|
|
7
|
+
private readonly grammar;
|
|
8
|
+
constructor(connection: Connection | null, grammar: SchemaGrammar);
|
|
9
|
+
createTable(tableName: string, structMethod: (blueprint: Blueprint) => void): Promise<void>;
|
|
10
|
+
dropTable(tableName: string): Promise<void>;
|
|
11
|
+
tables(): Promise<any>;
|
|
12
|
+
tableExists(table_name: string): Promise<boolean>;
|
|
13
|
+
dropTableIfExists(tableName: string): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare abstract class QueryGrammar {
|
|
17
|
+
sqlParts: string[];
|
|
18
|
+
toSql(query: Query): CompiledSql;
|
|
19
|
+
compileSelect(selects: selectType[]): CompiledSql;
|
|
20
|
+
compileTable(tableName: string): CompiledSql;
|
|
21
|
+
compileJoin(joins: joinType[]): CompiledSql;
|
|
22
|
+
compileWhere(wheres: whereType[]): CompiledSql;
|
|
23
|
+
compileWhereOperation(w: whereOp): CompiledSql;
|
|
24
|
+
compileWhereOperationColumn(w: whereOpColumn): CompiledSql;
|
|
25
|
+
compileOrderBy(orderBy: string[]): CompiledSql;
|
|
26
|
+
compileLimit(limit: number | null): CompiledSql;
|
|
27
|
+
compileOffset(offset: number | null): CompiledSql;
|
|
28
|
+
abstract getVariablePlaceholder(): string;
|
|
29
|
+
compileWhereNull(w: whereNull): CompiledSql;
|
|
30
|
+
compileInsert(query: Query, data: Record<string, Parameter>): CompiledSql;
|
|
31
|
+
abstract compileInsertGetId(query: Query, data: Record<string, Parameter>, options: {
|
|
32
|
+
primaryKey: string[];
|
|
33
|
+
}): CompiledSql;
|
|
34
|
+
compileUpdate(query: Query, data: Record<string, Parameter>): CompiledSql;
|
|
35
|
+
compileDelete(query: Query): CompiledSql;
|
|
36
|
+
compileUpsert(query: Query, data: Record<string, Parameter>, conflictFields: string[], updateFields: string[]): CompiledSql;
|
|
37
|
+
compileGroupBy(groupBy: string[]): CompiledSql;
|
|
38
|
+
compileHaving(having: havingType[]): CompiledSql;
|
|
39
|
+
compileHavingOperation(w: whereOp): CompiledSql;
|
|
40
|
+
compileHavingRaw(w: whereRaw): CompiledSql;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type QueryParts = {
|
|
44
|
+
select: selectType[];
|
|
45
|
+
table: string;
|
|
46
|
+
join: joinType[];
|
|
47
|
+
where: whereType[];
|
|
48
|
+
groupBy: string[];
|
|
49
|
+
having: havingType[];
|
|
50
|
+
orderBy: string[];
|
|
51
|
+
limit: number | null;
|
|
52
|
+
offset: number | null;
|
|
53
|
+
};
|
|
54
|
+
declare class Query {
|
|
55
|
+
private readonly connection;
|
|
56
|
+
private readonly grammar;
|
|
57
|
+
allowedOperations: string[];
|
|
58
|
+
parts: QueryParts;
|
|
59
|
+
constructor(connection: Connection | null, grammar: QueryGrammar);
|
|
60
|
+
table(tableName: string): this;
|
|
61
|
+
whereOp(column: string, operation: (typeof this.allowedOperations)[number], value: Parameter, joinCondition?: JoinCondition, negateCondition?: boolean): this;
|
|
62
|
+
whereColumn(column1: string, operation: (typeof this.allowedOperations)[number], column2: string, joinCondition?: JoinCondition, negateCondition?: boolean): this;
|
|
63
|
+
whereNull(column: string, joinCondition?: JoinCondition, negateCondition?: boolean): this;
|
|
64
|
+
clearWhere(): this;
|
|
65
|
+
select(selects: selectType[]): this;
|
|
66
|
+
groupBy(columns: string[]): this;
|
|
67
|
+
havingOp(column: string, operation: (typeof this.allowedOperations)[number], value: Parameter, joinCondition?: JoinCondition, negateCondition?: boolean): this;
|
|
68
|
+
havingRaw(sql: string, bindings: Parameter[], joinCondition?: JoinCondition, negateCondition?: boolean): this;
|
|
69
|
+
orderBy(column: string, direction?: 'asc' | 'desc'): this;
|
|
70
|
+
limit(limit: number): this;
|
|
71
|
+
offset(offset: number): this;
|
|
72
|
+
toSql(): CompiledSql;
|
|
73
|
+
get(): Promise<any>;
|
|
74
|
+
getCursor(): Promise<any>;
|
|
75
|
+
getConnection(): Connection | null;
|
|
76
|
+
insert(data: Record<string, Parameter>): Promise<any>;
|
|
77
|
+
insertGetId(data: Record<string, Parameter>, options?: {
|
|
78
|
+
primaryKey: string[];
|
|
79
|
+
}): Promise<any>;
|
|
80
|
+
update(data: Record<string, Parameter>): Promise<any>;
|
|
81
|
+
upsert(data: Record<string, Parameter>, uniqueColumns: string[], updateColumns: string[]): Promise<any>;
|
|
82
|
+
delete(): Promise<any>;
|
|
83
|
+
innerJoin(table: string, condtions: whereType[]): this;
|
|
84
|
+
leftJoin(table: string, condtions: whereType[]): this;
|
|
85
|
+
rightJoin(table: string, condtions: whereType[]): this;
|
|
86
|
+
fullJoin(table: string, condtions: whereType[]): this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
declare abstract class Connection {
|
|
90
|
+
abstract connect(): Promise<boolean>;
|
|
91
|
+
abstract runQuery(sql: CompiledSql): Promise<any>;
|
|
92
|
+
abstract runCursor(sql: CompiledSql): Promise<any>;
|
|
93
|
+
abstract disconnect(): Promise<boolean>;
|
|
94
|
+
abstract getQuery(): Query;
|
|
95
|
+
abstract getSchema(): Schema;
|
|
96
|
+
abstract beginTransaction(): Promise<void>;
|
|
97
|
+
abstract commit(): Promise<void>;
|
|
98
|
+
abstract rollback(): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { Connection as C, type QueryParts as Q, Schema as S, Query as a, QueryGrammar as b };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Connection_exports = {};
|
|
20
|
+
__export(Connection_exports, {
|
|
21
|
+
Connection: () => Connection
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(Connection_exports);
|
|
24
|
+
class Connection {
|
|
25
|
+
}
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
Connection
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=Connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Connection.ts"],"sourcesContent":["import { Schema } from './Schema';\nimport { Query } from './Query';\nimport { CompiledSql } from './types';\n\nexport abstract class Connection {\n abstract connect(): Promise<boolean>;\n abstract runQuery(sql: CompiledSql): Promise<any>;\n abstract runCursor(sql: CompiledSql): Promise<any>;\n abstract disconnect(): Promise<boolean>;\n abstract getQuery(): Query;\n abstract getSchema(): Schema;\n abstract beginTransaction(): Promise<void>;\n abstract commit(): Promise<void>;\n abstract rollback(): Promise<void>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAe,WAAW;AAUjC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Connection.ts"],"sourcesContent":["import { Schema } from './Schema';\nimport { Query } from './Query';\nimport { CompiledSql } from './types';\n\nexport abstract class Connection {\n abstract connect(): Promise<boolean>;\n abstract runQuery(sql: CompiledSql): Promise<any>;\n abstract runCursor(sql: CompiledSql): Promise<any>;\n abstract disconnect(): Promise<boolean>;\n abstract getQuery(): Query;\n abstract getSchema(): Schema;\n abstract beginTransaction(): Promise<void>;\n abstract commit(): Promise<void>;\n abstract rollback(): Promise<void>;\n}\n"],"mappings":"AAIO,MAAe,WAAW;AAUjC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { E as Expression } from './types-C_aDrXJN.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { E as Expression } from './types-C_aDrXJN.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Expression_exports = {};
|
|
20
|
+
__export(Expression_exports, {
|
|
21
|
+
Expression: () => Expression
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(Expression_exports);
|
|
24
|
+
class Expression {
|
|
25
|
+
constructor(sql = "", bindings = []) {
|
|
26
|
+
this.sql = sql;
|
|
27
|
+
this.bindings = bindings;
|
|
28
|
+
}
|
|
29
|
+
toCompiledSql() {
|
|
30
|
+
return { sql: this.sql, bindings: this.bindings };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
Expression
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=Expression.js.map
|