waibu-db 2.10.2 → 2.10.3

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.
@@ -8,7 +8,7 @@ async function getRecord ({ model, req, reply, id, options = {}, transaction } =
8
8
  opts.trx = opts.trx || trx
9
9
  const data = await getOneRecord.call(me, mdl, recId, filter, opts)
10
10
  if (attachment) data._attachment = await mdl.findAttachment(data.id, { stats, mimeType })
11
- return { data }
11
+ return data
12
12
  }
13
13
 
14
14
  return opts.trx === true ? await mdl.transaction(handler) : await handler()
@@ -6,7 +6,8 @@ async function removeRecord ({ model, req, reply, id, options = {}, transaction
6
6
 
7
7
  async function handler (trx) {
8
8
  opts.trx = opts.trx || trx
9
- opts._data = await getOneRecord.call(me, mdl, recId, filter, opts)
9
+ const resp = await getOneRecord.call(me, mdl, recId, filter, opts)
10
+ opts._data = resp.data
10
11
  return await mdl.removeRecord(recId, opts)
11
12
  }
12
13
 
@@ -6,7 +6,8 @@ async function updateRecord ({ model, req, reply, id, body, options = {}, transa
6
6
 
7
7
  async function handler (trx) {
8
8
  opts.trx = opts.trx || trx
9
- opts._data = await getOneRecord.call(me, mdl, recId, filter, opts)
9
+ const resp = await getOneRecord.call(me, mdl, recId, filter, opts)
10
+ opts._data = resp.data
10
11
  const ret = await mdl.updateRecord(recId, input, opts)
11
12
  if (attachment) ret.data._attachment = await mdl.findAttachment(id, { stats, mimeType })
12
13
  return ret
package/lib/util.js CHANGED
@@ -54,12 +54,12 @@ export async function prepCrud ({ model, body, id, req, reply, transaction, opti
54
54
  }
55
55
 
56
56
  export async function getOneRecord (model, id, filter, options) {
57
- const { cloneDeep, pick } = this.app.lib._
57
+ const { cloneDeep, pick, isEmpty } = this.app.lib._
58
58
  let query = cloneDeep(filter.query || {})
59
59
  query = { $and: [query, { id }] }
60
60
  const opts = pick(options, ['forceNoHidden', 'trx', 'req', 'refs'])
61
- opts.dataOnly = true
61
+ opts.dataOnly = false
62
62
  const data = await model.findOneRecord({ query }, opts)
63
- if (!data && options.throwNotFound) throw this.error('_notFound')
63
+ if (isEmpty(data.data) && options.throwNotFound) throw this.error('_notFound')
64
64
  return data
65
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "2.10.2",
3
+ "version": "2.10.3",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-03-25
4
+
5
+ - [2.10.13] Bug fix in ```getOneRecord()```
6
+
3
7
  ## 2026-03-22
4
8
 
5
9
  - [2.10.1] Bug fix in reference records