@less-is-more/less-js 1.4.20 → 1.4.21
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/package.json +1 -1
- package/src/db.js +5 -2
package/package.json
CHANGED
package/src/db.js
CHANGED
|
@@ -94,12 +94,14 @@ module.exports = class Db {
|
|
|
94
94
|
needDelete = false,
|
|
95
95
|
compareColumn = []
|
|
96
96
|
) {
|
|
97
|
+
let updateData = [];
|
|
98
|
+
let addData = [];
|
|
97
99
|
for (let nNewData of newData) {
|
|
98
100
|
const nOldIndex = oldData.findIndex(
|
|
99
101
|
(nOld) => nOld[keyColumn] == nNewData[keyColumn]
|
|
100
102
|
);
|
|
101
103
|
if (nOldIndex == -1) {
|
|
102
|
-
await this.add(model, nNewData);
|
|
104
|
+
addData.push(await this.add(model, nNewData));
|
|
103
105
|
} else {
|
|
104
106
|
const nOldData = oldData[nOldIndex];
|
|
105
107
|
let needUpdate = false;
|
|
@@ -127,7 +129,7 @@ module.exports = class Db {
|
|
|
127
129
|
for (let nColumn of compareColumn) {
|
|
128
130
|
setValues[nColumn] = nNewData[nColumn];
|
|
129
131
|
}
|
|
130
|
-
await this.update(model, setValues, where);
|
|
132
|
+
updateData.push(await this.update(model, setValues, where));
|
|
131
133
|
}
|
|
132
134
|
// 剔除已经处理的
|
|
133
135
|
oldData.splice(nOldIndex, 1);
|
|
@@ -139,6 +141,7 @@ module.exports = class Db {
|
|
|
139
141
|
await n.destroy();
|
|
140
142
|
}
|
|
141
143
|
}
|
|
144
|
+
return { addData: addData, updateData: updateData };
|
|
142
145
|
}
|
|
143
146
|
|
|
144
147
|
/**
|