dobo 2.37.0 → 2.37.2
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/index.js +23 -2
- package/lib/factory/adapter.js +4 -4
- package/lib/factory/model/sanitize-fixture.js +1 -1
- package/lib/factory/model.js +1 -0
- package/package.json +2 -2
- package/wiki/CHANGES.md +7 -0
package/index.js
CHANGED
|
@@ -613,12 +613,33 @@ async function factory (pkgName) {
|
|
|
613
613
|
}
|
|
614
614
|
|
|
615
615
|
reviveRegexInJson = (input, returnObject = true) => {
|
|
616
|
-
const { isPlainObject } = this.app.lib._
|
|
616
|
+
const { isPlainObject, isArray } = this.app.lib._
|
|
617
617
|
if (isPlainObject(input)) input = JSON.stringify(input)
|
|
618
618
|
const result = JSON.parse(input, (key, value) => {
|
|
619
|
-
if (Array.isArray(value) && value[0] === '__REGEXP__')
|
|
619
|
+
if (Array.isArray(value) && value[0] === '__REGEXP__') {
|
|
620
|
+
return { $regex: new RegExp(value[1], value[2]) }
|
|
621
|
+
}
|
|
620
622
|
return value
|
|
621
623
|
})
|
|
624
|
+
|
|
625
|
+
const cleanRegex = (obj) => {
|
|
626
|
+
const keys = Object.keys(obj)
|
|
627
|
+
keys.forEach(k => {
|
|
628
|
+
const v = obj[k]
|
|
629
|
+
if (isPlainObject(v)) {
|
|
630
|
+
if (k === '$regex' && isPlainObject(v) && v.$regex) obj[k] = v.$regex
|
|
631
|
+
else obj[k] = cleanRegex(v)
|
|
632
|
+
} else if (isArray(v)) {
|
|
633
|
+
v.forEach((i, idx) => {
|
|
634
|
+
if (isPlainObject(i) && i.$regex && i.$regex.$regex) obj[k][idx] = i.$regex.$regex
|
|
635
|
+
else obj[k][idx] = cleanRegex(i)
|
|
636
|
+
})
|
|
637
|
+
}
|
|
638
|
+
})
|
|
639
|
+
return obj
|
|
640
|
+
}
|
|
641
|
+
cleanRegex(result)
|
|
642
|
+
|
|
622
643
|
return returnObject ? result : JSON.stringify(result)
|
|
623
644
|
}
|
|
624
645
|
}
|
package/lib/factory/adapter.js
CHANGED
|
@@ -452,7 +452,7 @@ async function adapterFactory () {
|
|
|
452
452
|
if (!this.support.uniqueIndex) await this._checkUnique(model, body, options)
|
|
453
453
|
}
|
|
454
454
|
if (!options.noIdCheck && isSet(body.id)) {
|
|
455
|
-
const resp = await this.getRecord(model, body.id, { noMagic: true })
|
|
455
|
+
const resp = await this.getRecord(model, body.id, { ...options, noMagic: true })
|
|
456
456
|
if (!isEmpty(resp.data)) throw this.plugin.error('recordExists%s%s', body.id, model.name)
|
|
457
457
|
}
|
|
458
458
|
body = this.sanitizeBody(model, body)
|
|
@@ -536,7 +536,7 @@ async function adapterFactory () {
|
|
|
536
536
|
if (!this.support.uniqueIndex) await this._checkUnique(model, body, options)
|
|
537
537
|
}
|
|
538
538
|
if (!options._data) {
|
|
539
|
-
const resp = await this.getRecord(model, id, { noMagic: true })
|
|
539
|
+
const resp = await this.getRecord(model, id, { ...options, noMagic: true })
|
|
540
540
|
if (!resp.data) throw this.plugin.error('recordNotFound%s%s', id, model.name)
|
|
541
541
|
options._data = resp.data
|
|
542
542
|
}
|
|
@@ -573,7 +573,7 @@ async function adapterFactory () {
|
|
|
573
573
|
}
|
|
574
574
|
if (isSet(body.id)) {
|
|
575
575
|
if (!options._data) {
|
|
576
|
-
const resp = await this.getRecord(model, body.id, { noMagic: true })
|
|
576
|
+
const resp = await this.getRecord(model, body.id, { ...options, noMagic: true })
|
|
577
577
|
if (!resp.data) throw this.plugin.error('recordNotFound%s%s', body.id, model.name)
|
|
578
578
|
options._data = resp.data
|
|
579
579
|
}
|
|
@@ -604,7 +604,7 @@ async function adapterFactory () {
|
|
|
604
604
|
*/
|
|
605
605
|
async _removeRecord (model, id, options = {}) {
|
|
606
606
|
if (!options._data) {
|
|
607
|
-
const resp = await this.getRecord(model, id, { noMagic: true })
|
|
607
|
+
const resp = await this.getRecord(model, id, { ...options, noMagic: true })
|
|
608
608
|
if (!resp.data) throw this.plugin.error('recordNotFound%s%s', id, model.name)
|
|
609
609
|
options._data = resp.data
|
|
610
610
|
}
|
|
@@ -47,7 +47,7 @@ async function sanitizeFixture (params = {}, opts = {}) {
|
|
|
47
47
|
if (val === null) body[key] = undefined
|
|
48
48
|
else {
|
|
49
49
|
const prop = this.properties.find(item => item.name === key)
|
|
50
|
-
if (prop && ['string', 'text'].includes(prop.type)) body[key] += ''
|
|
50
|
+
if (prop && ['string', 'text'].includes(prop.type) && isSet(body[key])) body[key] += ''
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
return body
|
package/lib/factory/model.js
CHANGED
|
@@ -450,6 +450,7 @@ async function modelFactory () {
|
|
|
450
450
|
for (const key in lookupValue) {
|
|
451
451
|
query = query.replaceAll(`{${key}}`, lookupValue[key])
|
|
452
452
|
}
|
|
453
|
+
if (query.includes('{') && query.includes('}')) return null
|
|
453
454
|
if (isEmpty(field)) field = 'id'
|
|
454
455
|
const { getModel } = this.app.dobo
|
|
455
456
|
const ref = getModel(model)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dobo",
|
|
3
|
-
"version": "2.37.
|
|
3
|
+
"version": "2.37.2",
|
|
4
4
|
"description": "DBMS for Bajo Framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/ardhi/dobo#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@tryghost/nql": "^0.
|
|
35
|
+
"@tryghost/nql": "^0.13.2",
|
|
36
36
|
"joi": "^18.0.2",
|
|
37
37
|
"mingo": "^6.5.1",
|
|
38
38
|
"ulid": "^3.0.2",
|
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-08-13
|
|
4
|
+
|
|
5
|
+
- [2.37.1] Bug fix in `adapter.js` to pass options when calling `getRecord()`
|
|
6
|
+
- [2.37.1] Bug fix in `model._simpleLookup()` to return `null` if query string is not right
|
|
7
|
+
- [2.37.1] Bug fix in `model.sanitizeFixture()` to not sanitize value that is `null` or `undefined`
|
|
8
|
+
- [2.37.2] Bug fix in `reviveRegexInJson()` when handling with regex
|
|
9
|
+
|
|
3
10
|
## 2026-08-06
|
|
4
11
|
|
|
5
12
|
- [2.37.0] Update `memory.connect()` to use the new `app.lib.setInterval()`
|