dobo 2.36.2 → 2.37.1

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.
@@ -28,6 +28,7 @@ async function memoryAdapterFactory () {
28
28
  async connect (connection, noRebuild) {
29
29
  const conn = this.plugin.getConnection('memory')
30
30
  const { fs } = this.app.lib
31
+ const { setInterval } = this.app.lib
31
32
  const dir = `${this.app.getPluginDataDir(this.plugin.ns)}/memDb/data` // persistence dir
32
33
  fs.ensureDirSync(dir)
33
34
  conn.persistences = conn.persistences ?? []
@@ -51,7 +52,7 @@ async function memoryAdapterFactory () {
51
52
  else this.storage[model.name] = data
52
53
  } else await model.loadFixtures({ ignoreError: false })
53
54
  }
54
- setInterval(() => {
55
+ async function handler () {
55
56
  if (!this.saving) return
56
57
  this.saving = true
57
58
  for (const model of models) {
@@ -61,7 +62,9 @@ async function memoryAdapterFactory () {
61
62
  } catch (err) {}
62
63
  }
63
64
  this.saving = false
64
- }, this.plugin.config.memDb.persistenceDur)
65
+ }
66
+
67
+ await setInterval(handler, this.plugin.config.memDb.persistenceDur, { lockFile: 'memDbPersistence', scope: this })
65
68
  }
66
69
 
67
70
  async _getOldRecord (model, id, options = {}) {
@@ -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
@@ -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.36.2",
3
+ "version": "2.37.1",
4
4
  "description": "DBMS for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,15 @@
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
+
9
+ ## 2026-08-06
10
+
11
+ - [2.37.0] Update `memory.connect()` to use the new `app.lib.setInterval()`
12
+
3
13
  ## 2026-08-03
4
14
 
5
15
  - [2.36.2] Bug fix in `model.rebuildModel()`