@dyrected/db-mysql 2.18.0 → 2.19.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/dist/index.cjs +4 -2
- package/dist/index.js +4 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -590,6 +590,8 @@ FIX INSTRUCTIONS:
|
|
|
590
590
|
const colConfig = this.collectionConfigs.get(params.collection);
|
|
591
591
|
const id = params.data.id ?? (0, import_core.generateDocumentId)(colConfig || params.collection);
|
|
592
592
|
const now = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", "");
|
|
593
|
+
const createdAt = params.data.createdAt ? toDatetimeColumn(params.data.createdAt) : now;
|
|
594
|
+
const updatedAt = params.data.updatedAt ? toDatetimeColumn(params.data.updatedAt) : now;
|
|
593
595
|
const data = { ...params.data };
|
|
594
596
|
delete data.id;
|
|
595
597
|
delete data.createdAt;
|
|
@@ -604,9 +606,9 @@ FIX INSTRUCTIONS:
|
|
|
604
606
|
}
|
|
605
607
|
const colNames = ["id", "data", "created_at", "updated_at", ...Object.keys(promotedValues).map((k) => `\`${k}\``)];
|
|
606
608
|
const placeholders = colNames.map(() => "?").join(", ");
|
|
607
|
-
const values = [id, JSON.stringify(data),
|
|
609
|
+
const values = [id, JSON.stringify(data), createdAt, updatedAt, ...Object.values(promotedValues)];
|
|
608
610
|
await this.query(`INSERT INTO \`${tableName}\` (${colNames.join(", ")}) VALUES (${placeholders})`, values);
|
|
609
|
-
return { id, ...data, ...promotedValues, ...this.isoDates(dateCols, promotedValues), createdAt:
|
|
611
|
+
return { id, ...data, ...promotedValues, ...this.isoDates(dateCols, promotedValues), createdAt: fromDatetimeColumn(createdAt), updatedAt: fromDatetimeColumn(updatedAt) };
|
|
610
612
|
}
|
|
611
613
|
async update(params) {
|
|
612
614
|
if (!this.inTransaction) await this.ensureTable(params.collection);
|
package/dist/index.js
CHANGED
|
@@ -554,6 +554,8 @@ FIX INSTRUCTIONS:
|
|
|
554
554
|
const colConfig = this.collectionConfigs.get(params.collection);
|
|
555
555
|
const id = params.data.id ?? generateDocumentId(colConfig || params.collection);
|
|
556
556
|
const now = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", "");
|
|
557
|
+
const createdAt = params.data.createdAt ? toDatetimeColumn(params.data.createdAt) : now;
|
|
558
|
+
const updatedAt = params.data.updatedAt ? toDatetimeColumn(params.data.updatedAt) : now;
|
|
557
559
|
const data = { ...params.data };
|
|
558
560
|
delete data.id;
|
|
559
561
|
delete data.createdAt;
|
|
@@ -568,9 +570,9 @@ FIX INSTRUCTIONS:
|
|
|
568
570
|
}
|
|
569
571
|
const colNames = ["id", "data", "created_at", "updated_at", ...Object.keys(promotedValues).map((k) => `\`${k}\``)];
|
|
570
572
|
const placeholders = colNames.map(() => "?").join(", ");
|
|
571
|
-
const values = [id, JSON.stringify(data),
|
|
573
|
+
const values = [id, JSON.stringify(data), createdAt, updatedAt, ...Object.values(promotedValues)];
|
|
572
574
|
await this.query(`INSERT INTO \`${tableName}\` (${colNames.join(", ")}) VALUES (${placeholders})`, values);
|
|
573
|
-
return { id, ...data, ...promotedValues, ...this.isoDates(dateCols, promotedValues), createdAt:
|
|
575
|
+
return { id, ...data, ...promotedValues, ...this.isoDates(dateCols, promotedValues), createdAt: fromDatetimeColumn(createdAt), updatedAt: fromDatetimeColumn(updatedAt) };
|
|
574
576
|
}
|
|
575
577
|
async update(params) {
|
|
576
578
|
if (!this.inTransaction) await this.ensureTable(params.collection);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dyrected/db-mysql",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"description": "MySQL adapter for Dyrected CMS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"mysql2": "^3.22.3",
|
|
21
|
-
"@dyrected/core": "^2.
|
|
21
|
+
"@dyrected/core": "^2.19.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"tsup": "^8.0.0",
|