@atscript/db-mysql 0.1.83 → 0.1.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +12 -8
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +12 -8
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -57,8 +57,8 @@ function buildSelect(table, where, controls) {
|
|
|
57
57
|
/**
|
|
58
58
|
* Builds an UPDATE ... SET ... WHERE statement with optional LIMIT.
|
|
59
59
|
*/
|
|
60
|
-
function buildUpdate(table, data, where, limit, ops) {
|
|
61
|
-
return (0, _atscript_db_sql_tools.buildUpdate)(mysqlDialect, table, data, where, limit, ops);
|
|
60
|
+
function buildUpdate(table, data, where, limit, ops, versionColumn, expectedVersion) {
|
|
61
|
+
return (0, _atscript_db_sql_tools.buildUpdate)(mysqlDialect, table, data, where, limit, ops, versionColumn, expectedVersion);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Builds a DELETE ... WHERE statement with optional LIMIT.
|
|
@@ -522,9 +522,10 @@ var MysqlAdapter = class MysqlAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
522
522
|
this._log(sql, params);
|
|
523
523
|
return this._exec().all(sql, params);
|
|
524
524
|
}
|
|
525
|
-
async updateOne(filter, data, ops) {
|
|
525
|
+
async updateOne(filter, data, ops, expectedVersion) {
|
|
526
526
|
const where = buildWhere(filter);
|
|
527
|
-
const
|
|
527
|
+
const versionColumn = this._table.versionColumn;
|
|
528
|
+
const { sql, params } = buildUpdate(this.resolveTableName(), data, where, 1, ops, versionColumn, expectedVersion);
|
|
528
529
|
this._log(sql, params);
|
|
529
530
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
530
531
|
return {
|
|
@@ -534,7 +535,8 @@ var MysqlAdapter = class MysqlAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
534
535
|
}
|
|
535
536
|
async updateMany(filter, data, ops) {
|
|
536
537
|
const where = buildWhere(filter);
|
|
537
|
-
const
|
|
538
|
+
const versionColumn = this._table.versionColumn;
|
|
539
|
+
const { sql, params } = buildUpdate(this.resolveTableName(), data, where, void 0, ops, versionColumn);
|
|
538
540
|
this._log(sql, params);
|
|
539
541
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
540
542
|
return {
|
|
@@ -542,9 +544,10 @@ var MysqlAdapter = class MysqlAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
542
544
|
modifiedCount: result.changedRows
|
|
543
545
|
};
|
|
544
546
|
}
|
|
545
|
-
async replaceOne(filter, data) {
|
|
547
|
+
async replaceOne(filter, data, expectedVersion) {
|
|
546
548
|
const where = buildWhere(filter);
|
|
547
|
-
const
|
|
549
|
+
const versionColumn = this._table.versionColumn;
|
|
550
|
+
const { sql, params } = buildUpdate(this.resolveTableName(), data, where, 1, void 0, versionColumn, expectedVersion);
|
|
548
551
|
this._log(sql, params);
|
|
549
552
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
550
553
|
return {
|
|
@@ -554,7 +557,8 @@ var MysqlAdapter = class MysqlAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
554
557
|
}
|
|
555
558
|
async replaceMany(filter, data) {
|
|
556
559
|
const where = buildWhere(filter);
|
|
557
|
-
const
|
|
560
|
+
const versionColumn = this._table.versionColumn;
|
|
561
|
+
const { sql, params } = buildUpdate(this.resolveTableName(), data, where, void 0, void 0, versionColumn);
|
|
558
562
|
this._log(sql, params);
|
|
559
563
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
560
564
|
return {
|
package/dist/index.d.cts
CHANGED
|
@@ -153,9 +153,9 @@ declare class MysqlAdapter extends BaseDbAdapter {
|
|
|
153
153
|
findMany(query: DbQuery): Promise<Array<Record<string, unknown>>>;
|
|
154
154
|
count(query: DbQuery): Promise<number>;
|
|
155
155
|
aggregate(query: DbQuery): Promise<Array<Record<string, unknown>>>;
|
|
156
|
-
updateOne(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps): Promise<TDbUpdateResult>;
|
|
156
|
+
updateOne(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps, expectedVersion?: number): Promise<TDbUpdateResult>;
|
|
157
157
|
updateMany(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps): Promise<TDbUpdateResult>;
|
|
158
|
-
replaceOne(filter: FilterExpr, data: Record<string, unknown
|
|
158
|
+
replaceOne(filter: FilterExpr, data: Record<string, unknown>, expectedVersion?: number): Promise<TDbUpdateResult>;
|
|
159
159
|
replaceMany(filter: FilterExpr, data: Record<string, unknown>): Promise<TDbUpdateResult>;
|
|
160
160
|
deleteOne(filter: FilterExpr): Promise<TDbDeleteResult>;
|
|
161
161
|
deleteMany(filter: FilterExpr): Promise<TDbDeleteResult>;
|
package/dist/index.d.mts
CHANGED
|
@@ -153,9 +153,9 @@ declare class MysqlAdapter extends BaseDbAdapter {
|
|
|
153
153
|
findMany(query: DbQuery): Promise<Array<Record<string, unknown>>>;
|
|
154
154
|
count(query: DbQuery): Promise<number>;
|
|
155
155
|
aggregate(query: DbQuery): Promise<Array<Record<string, unknown>>>;
|
|
156
|
-
updateOne(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps): Promise<TDbUpdateResult>;
|
|
156
|
+
updateOne(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps, expectedVersion?: number): Promise<TDbUpdateResult>;
|
|
157
157
|
updateMany(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps): Promise<TDbUpdateResult>;
|
|
158
|
-
replaceOne(filter: FilterExpr, data: Record<string, unknown
|
|
158
|
+
replaceOne(filter: FilterExpr, data: Record<string, unknown>, expectedVersion?: number): Promise<TDbUpdateResult>;
|
|
159
159
|
replaceMany(filter: FilterExpr, data: Record<string, unknown>): Promise<TDbUpdateResult>;
|
|
160
160
|
deleteOne(filter: FilterExpr): Promise<TDbDeleteResult>;
|
|
161
161
|
deleteMany(filter: FilterExpr): Promise<TDbDeleteResult>;
|
package/dist/index.mjs
CHANGED
|
@@ -56,8 +56,8 @@ function buildSelect$1(table, where, controls) {
|
|
|
56
56
|
/**
|
|
57
57
|
* Builds an UPDATE ... SET ... WHERE statement with optional LIMIT.
|
|
58
58
|
*/
|
|
59
|
-
function buildUpdate$1(table, data, where, limit, ops) {
|
|
60
|
-
return buildUpdate(mysqlDialect, table, data, where, limit, ops);
|
|
59
|
+
function buildUpdate$1(table, data, where, limit, ops, versionColumn, expectedVersion) {
|
|
60
|
+
return buildUpdate(mysqlDialect, table, data, where, limit, ops, versionColumn, expectedVersion);
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Builds a DELETE ... WHERE statement with optional LIMIT.
|
|
@@ -521,9 +521,10 @@ var MysqlAdapter = class MysqlAdapter extends BaseDbAdapter {
|
|
|
521
521
|
this._log(sql, params);
|
|
522
522
|
return this._exec().all(sql, params);
|
|
523
523
|
}
|
|
524
|
-
async updateOne(filter, data, ops) {
|
|
524
|
+
async updateOne(filter, data, ops, expectedVersion) {
|
|
525
525
|
const where = buildWhere(filter);
|
|
526
|
-
const
|
|
526
|
+
const versionColumn = this._table.versionColumn;
|
|
527
|
+
const { sql, params } = buildUpdate$1(this.resolveTableName(), data, where, 1, ops, versionColumn, expectedVersion);
|
|
527
528
|
this._log(sql, params);
|
|
528
529
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
529
530
|
return {
|
|
@@ -533,7 +534,8 @@ var MysqlAdapter = class MysqlAdapter extends BaseDbAdapter {
|
|
|
533
534
|
}
|
|
534
535
|
async updateMany(filter, data, ops) {
|
|
535
536
|
const where = buildWhere(filter);
|
|
536
|
-
const
|
|
537
|
+
const versionColumn = this._table.versionColumn;
|
|
538
|
+
const { sql, params } = buildUpdate$1(this.resolveTableName(), data, where, void 0, ops, versionColumn);
|
|
537
539
|
this._log(sql, params);
|
|
538
540
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
539
541
|
return {
|
|
@@ -541,9 +543,10 @@ var MysqlAdapter = class MysqlAdapter extends BaseDbAdapter {
|
|
|
541
543
|
modifiedCount: result.changedRows
|
|
542
544
|
};
|
|
543
545
|
}
|
|
544
|
-
async replaceOne(filter, data) {
|
|
546
|
+
async replaceOne(filter, data, expectedVersion) {
|
|
545
547
|
const where = buildWhere(filter);
|
|
546
|
-
const
|
|
548
|
+
const versionColumn = this._table.versionColumn;
|
|
549
|
+
const { sql, params } = buildUpdate$1(this.resolveTableName(), data, where, 1, void 0, versionColumn, expectedVersion);
|
|
547
550
|
this._log(sql, params);
|
|
548
551
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
549
552
|
return {
|
|
@@ -553,7 +556,8 @@ var MysqlAdapter = class MysqlAdapter extends BaseDbAdapter {
|
|
|
553
556
|
}
|
|
554
557
|
async replaceMany(filter, data) {
|
|
555
558
|
const where = buildWhere(filter);
|
|
556
|
-
const
|
|
559
|
+
const versionColumn = this._table.versionColumn;
|
|
560
|
+
const { sql, params } = buildUpdate$1(this.resolveTableName(), data, where, void 0, void 0, versionColumn);
|
|
557
561
|
this._log(sql, params);
|
|
558
562
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
559
563
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/db-mysql",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.85",
|
|
4
4
|
"description": "MySQL adapter for @atscript/db with mysql2 driver support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"@atscript/typescript": "^0.1.59",
|
|
53
53
|
"@uniqu/core": "^0.1.6",
|
|
54
54
|
"mysql2": ">=3.0.0",
|
|
55
|
-
"@atscript/db
|
|
56
|
-
"@atscript/db": "^0.1.
|
|
55
|
+
"@atscript/db": "^0.1.85",
|
|
56
|
+
"@atscript/db-sql-tools": "^0.1.85"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"mysql2": {
|