dobo 2.30.2 → 2.30.4
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.
|
@@ -122,7 +122,7 @@ async function memoryDriverFactory () {
|
|
|
122
122
|
const { data: count = 0 } = await this.countRecord(model, filter, options)
|
|
123
123
|
const cursor = this._getCursor(model, filter)
|
|
124
124
|
if (sort) cursor.sort(sort)
|
|
125
|
-
|
|
125
|
+
cursor.skip(skip).limit(limit)
|
|
126
126
|
let result = { data: cursor.all(), page, limit, count, pages: Math.ceil(count / limit) }
|
|
127
127
|
if (!options.count) result = omit(result, ['count', 'pages'])
|
|
128
128
|
return result
|
package/lib/factory/driver.js
CHANGED
|
@@ -191,9 +191,10 @@ async function driverFactory () {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
async _prepBodyForCreate (model, body = {}, options = {}) {
|
|
194
|
+
const { callHandler } = this.app.bajo
|
|
194
195
|
const { isSet, generateId } = this.app.lib.aneka
|
|
195
196
|
for (const prop of model.getProperties({ noVirtual: true })) {
|
|
196
|
-
if (!isSet(body[prop.name])
|
|
197
|
+
if (isSet(prop.default) && (!options.noDefault) && (!isSet(body[prop.name]) || body[prop.name] === prop.default)) {
|
|
197
198
|
if (isFunction(prop.default)) body[prop.name] = await prop.default.call(model)
|
|
198
199
|
else if (typeof prop.default !== 'string') body[prop.name] = prop.default
|
|
199
200
|
else {
|
|
@@ -207,6 +208,9 @@ async function driverFactory () {
|
|
|
207
208
|
body[prop.name] = ulid().slice(0, prop.maxLength)
|
|
208
209
|
} else if (prop.default === 'generateid' && prop.type === 'string') {
|
|
209
210
|
body[prop.name] = generateId()
|
|
211
|
+
} else if (prop.default.startsWith('handler:')) {
|
|
212
|
+
const [, ...args] = prop.default.split(':')
|
|
213
|
+
if (args.length > 0) body[prop.name] = await callHandler(args.join(':'))
|
|
210
214
|
} else if (prop.default.startsWith('md5:') && prop.type === 'string') {
|
|
211
215
|
const [, field] = prop.default.split(':')
|
|
212
216
|
const fields = field.split(',')
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
*/
|
|
15
15
|
async function sanitizeBody ({ body = {}, partial, strict, extFields = [], noDefault, truncateString, onlyTypes = [], action } = {}) {
|
|
16
16
|
const { isSet } = this.app.lib.aneka
|
|
17
|
-
const { callHandler } = this.app.bajo
|
|
18
17
|
const { sanitizeByType } = this.app.dobo
|
|
19
|
-
const { omit, has
|
|
18
|
+
const { omit, has } = this.app.lib._
|
|
20
19
|
const result = {}
|
|
21
20
|
|
|
22
21
|
const sanitize = (name, type) => {
|
|
@@ -37,15 +36,6 @@ async function sanitizeBody ({ body = {}, partial, strict, extFields = [], noDef
|
|
|
37
36
|
result[prop.name] = body[prop.name]
|
|
38
37
|
if (prop.type === 'array' && isSet(result[prop.name]) && !Array.isArray(result[prop.name])) result[prop.name] = [result[prop.name]]
|
|
39
38
|
if (isSet(result[prop.name])) sanitize(prop.name, prop.type)
|
|
40
|
-
else {
|
|
41
|
-
if (isSet(prop.default) && !noDefault) {
|
|
42
|
-
result[prop.name] = prop.default
|
|
43
|
-
if (isString(prop.default) && prop.default.startsWith('handler:')) {
|
|
44
|
-
const [, ...args] = prop.default.split(':')
|
|
45
|
-
if (args.length > 0) result[prop.name] = await callHandler(args.join(':'))
|
|
46
|
-
} else sanitize(prop.name, prop.type)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
39
|
if (result[prop.name] === null) continue
|
|
50
40
|
if (truncateString && isSet(result[prop.name]) && ['string', 'text'].includes(prop.type)) result[prop.name] = result[prop.name].slice(0, prop.maxLength)
|
|
51
41
|
if (prop.name.endsWith('Id') && isSet(result[prop.name]) && prop.type === 'string' && ['smallint', 'integer'].includes(this.driver.idField.type)) result[prop.name] = result[prop.name] + ''
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-06-16
|
|
4
|
+
|
|
5
|
+
- [2.30.4] Bug fix in ```model.sanitizeBody()```
|
|
6
|
+
- [2.30.4] Bug fix in ```model._prepBodyForCreate()```
|
|
7
|
+
|
|
3
8
|
## 2026-06-13
|
|
4
9
|
|
|
5
10
|
- [2.30.2] Bug fix in ```model.findAllRecord()```
|
|
6
11
|
- [2.30.2] Bug fix in ```memory.findAllRecord()```
|
|
7
12
|
- [2.30.2] Bug fix in ```collect-models.js```
|
|
13
|
+
- [2.30.3] Bug fix in ```memory.findRecord()```
|
|
8
14
|
|
|
9
15
|
## 2026-06-12
|
|
10
16
|
|