@axiosleo/orm-mysql 0.5.5 → 0.5.6
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/index.d.ts +19 -0
- package/package.json +1 -1
- package/src/operator.js +4 -1
package/README.md
CHANGED
|
@@ -126,7 +126,7 @@ async function deleteExample() {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
async function subqueryExample() {
|
|
129
|
-
const query =
|
|
129
|
+
const query = handler.table("users", "u");
|
|
130
130
|
const subQuery = new Query("select");
|
|
131
131
|
subQuery.table("users").having("COUNT(*)", ">", 1);
|
|
132
132
|
|
package/index.d.ts
CHANGED
|
@@ -133,14 +133,33 @@ export declare class QueryHandler {
|
|
|
133
133
|
|
|
134
134
|
constructor(conn: Connection);
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* select table
|
|
138
|
+
* @param table
|
|
139
|
+
* @param alias
|
|
140
|
+
*/
|
|
136
141
|
table(table: string, alias?: string | null): QueryOperator;
|
|
137
142
|
|
|
143
|
+
/**
|
|
144
|
+
* execute sql
|
|
145
|
+
* @param options
|
|
146
|
+
*/
|
|
138
147
|
query(options: QueryOptions): Promise<any>;
|
|
139
148
|
|
|
149
|
+
/**
|
|
150
|
+
* insert or update
|
|
151
|
+
* @param tableName
|
|
152
|
+
* @param data
|
|
153
|
+
* @param condition
|
|
154
|
+
*/
|
|
140
155
|
upsert(tableName: string, data: any, condition: Record<string, ConditionValueType>): Promise<OkPacket>;
|
|
141
156
|
}
|
|
142
157
|
|
|
143
158
|
export declare class TransactionOperator extends QueryOperator {
|
|
159
|
+
/**
|
|
160
|
+
* @example LOCK IN SHARE MODE
|
|
161
|
+
* @example FOR UPDATE
|
|
162
|
+
*/
|
|
144
163
|
append(suffix: string): this;
|
|
145
164
|
}
|
|
146
165
|
|
package/package.json
CHANGED
package/src/operator.js
CHANGED
|
@@ -26,7 +26,7 @@ class QueryOperator extends Query {
|
|
|
26
26
|
/**
|
|
27
27
|
* @param {*} conn
|
|
28
28
|
*/
|
|
29
|
-
constructor(conn) {
|
|
29
|
+
constructor(conn = null) {
|
|
30
30
|
super(null);
|
|
31
31
|
this.conn = conn;
|
|
32
32
|
}
|
|
@@ -40,6 +40,9 @@ class QueryOperator extends Query {
|
|
|
40
40
|
if (!this.options.operator) {
|
|
41
41
|
throw new Error('Invalid operator: ' + this.options.operator);
|
|
42
42
|
}
|
|
43
|
+
if (this.conn === null) {
|
|
44
|
+
throw new Error('Connection is null');
|
|
45
|
+
}
|
|
43
46
|
const builder = this.buildSql(this.options.operator);
|
|
44
47
|
const { sql, values } = builder;
|
|
45
48
|
const options = {
|