dobo 2.4.0 → 2.5.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/lib/factory/driver.js +15 -9
- package/lib/factory/model/_util.js +1 -1
- package/package.json +1 -1
- package/wiki/CHANGES.md +5 -0
package/lib/factory/driver.js
CHANGED
|
@@ -247,9 +247,11 @@ async function driverFactory () {
|
|
|
247
247
|
|
|
248
248
|
async _updateRecord (model, id, body = {}, options = {}) {
|
|
249
249
|
if (!this.support.uniqueIndex) await this._checkUnique(model, body, options)
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
250
|
+
if (!options._data) {
|
|
251
|
+
const resp = await this.getRecord(model, id, { noHook: true })
|
|
252
|
+
if (!resp.data) throw this.plugin.error('recordNotFound%s%s', id, model.name)
|
|
253
|
+
options._data = resp.data
|
|
254
|
+
}
|
|
253
255
|
const input = this.sanitizeBody(model, body, true)
|
|
254
256
|
delete input.id
|
|
255
257
|
const result = await this.updateRecord(model, id, input, options)
|
|
@@ -262,9 +264,11 @@ async function driverFactory () {
|
|
|
262
264
|
async _upsertRecord (model, body = {}, options = {}) {
|
|
263
265
|
if (!this.uniqueIndexSupport) await this._checkUnique(model, body, options)
|
|
264
266
|
if (isSet(body.id)) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
267
|
+
if (!options._data) {
|
|
268
|
+
const resp = await this.getRecord(model, body.id, { noHook: true })
|
|
269
|
+
if (!resp.data) throw this.plugin.error('recordNotFound%s%s', body.id, model.name)
|
|
270
|
+
options._data = resp.data
|
|
271
|
+
}
|
|
268
272
|
}
|
|
269
273
|
const input = this.sanitizeBody(model, body)
|
|
270
274
|
const result = await this.upsertRecord(model, input, options)
|
|
@@ -275,9 +279,11 @@ async function driverFactory () {
|
|
|
275
279
|
}
|
|
276
280
|
|
|
277
281
|
async _removeRecord (model, id, options = {}) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
282
|
+
if (!options._data) {
|
|
283
|
+
const resp = await this.getRecord(model, id, { noHook: true })
|
|
284
|
+
if (!resp.data) throw this.plugin.error('recordNotFound%s%s', id, model.name)
|
|
285
|
+
options._data = resp.data
|
|
286
|
+
}
|
|
281
287
|
const result = await this.removeRecord(model, id, options)
|
|
282
288
|
if (options.noResult) return
|
|
283
289
|
result.oldData = this.sanitizeRecord(model, result.oldData)
|
|
@@ -124,7 +124,7 @@ export async function copyAttachment (id, options = {}) {
|
|
|
124
124
|
if (parts.length === 0) continue
|
|
125
125
|
fieldName = setField ?? fieldName
|
|
126
126
|
const file = setFile ?? parts.join('@')
|
|
127
|
-
const opts = { source: f, fieldName, file, mimeType, stats, req
|
|
127
|
+
const opts = { source: f, fieldName, file, mimeType, stats, req }
|
|
128
128
|
const rec = await this.createAttachment(id, opts)
|
|
129
129
|
if (!rec) continue
|
|
130
130
|
delete rec.dir
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-01-30
|
|
4
|
+
|
|
5
|
+
- [2.5.0] Add feature to push custom ```options._data```. If provided, this will be used instead of auto generated one.
|
|
6
|
+
- [2.5.0] Remove ```silent``` in ```options``` object
|
|
7
|
+
|
|
3
8
|
## 2026-01-29
|
|
4
9
|
|
|
5
10
|
- [2.4.0] Add ```bulkCreateRecords()``` on model & driver
|