@inflector/optima 1.0.4 → 1.0.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/dist/index.js +8 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -577,8 +577,12 @@ var OptimaTable = class _OptimaTable {
|
|
|
577
577
|
const valuesBlock = Records.map((r) => {
|
|
578
578
|
const orderedValues = columnKeys.map((key) => {
|
|
579
579
|
let v = r[key];
|
|
580
|
-
if (v == null
|
|
581
|
-
|
|
580
|
+
if (v == null) {
|
|
581
|
+
if (typeof this.Columns[key].config.default === "function") {
|
|
582
|
+
v = this.Columns[key].config.default();
|
|
583
|
+
} else if (this.Columns[key].config.defaultNow) {
|
|
584
|
+
v = /* @__PURE__ */ new Date();
|
|
585
|
+
}
|
|
582
586
|
}
|
|
583
587
|
return escape(v);
|
|
584
588
|
});
|
|
@@ -590,6 +594,7 @@ ${valuesBlock}${isReturning ? "\nRETURNING *" : ""};`;
|
|
|
590
594
|
};
|
|
591
595
|
this.BuildUpdate = (TableName, changes, options) => {
|
|
592
596
|
const { where, returning } = options;
|
|
597
|
+
console.log(changes);
|
|
593
598
|
const setClauses = [];
|
|
594
599
|
for (const [key, value] of Object.entries(changes)) {
|
|
595
600
|
if (value !== void 0) {
|
|
@@ -778,7 +783,7 @@ ${valuesBlock}${isReturning ? "\nRETURNING *" : ""};`;
|
|
|
778
783
|
return createFluentBuilder(async (data) => {
|
|
779
784
|
this.Validate(record);
|
|
780
785
|
record = this.Transform(record);
|
|
781
|
-
const PotentialyUpdated = await this.Get().where(
|
|
786
|
+
const PotentialyUpdated = await this.Get().where(data.where);
|
|
782
787
|
if (PotentialyUpdated.length == 0) return [];
|
|
783
788
|
else {
|
|
784
789
|
const { sql } = this.BuildUpdate(this.Name, record, data);
|