waibu-db 2.3.1 → 2.3.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import attachmentHandler from './helper/attachment-handler.js'
|
|
2
2
|
|
|
3
|
-
async function detailsHandler ({ req, reply, model, params = {}, id, template, addOnsHandler, templateDisabled = 'waibuDb.template:/disabled.html', options } = {}) {
|
|
3
|
+
async function detailsHandler ({ req, reply, model, params = {}, id, template, addOnsHandler, templateDisabled = 'waibuDb.template:/disabled.html', options = {} } = {}) {
|
|
4
4
|
const { pascalCase } = this.app.lib.aneka
|
|
5
5
|
const { getRecord, getSchemaExt } = this.app.waibuDb
|
|
6
6
|
const { merge } = this.app.lib._
|
|
@@ -2,7 +2,7 @@ import { prepCrud, getOneRecord } from '../util.js'
|
|
|
2
2
|
|
|
3
3
|
async function removeRecord ({ model, req, reply, id, options = {} }) {
|
|
4
4
|
const { model: mdl, recId, opts, filter } = await prepCrud.call(this, { model, req, reply, id, options, args: ['model', 'id'] })
|
|
5
|
-
opts._data = await getOneRecord(
|
|
5
|
+
opts._data = await getOneRecord.call(this, mdl, recId, filter, options)
|
|
6
6
|
const result = await mdl.removeRecord(recId, opts)
|
|
7
7
|
return result
|
|
8
8
|
}
|
|
@@ -2,7 +2,7 @@ import { prepCrud, getOneRecord } from '../util.js'
|
|
|
2
2
|
|
|
3
3
|
async function updateRecord ({ model, req, reply, id, body, options = {} }) {
|
|
4
4
|
const { model: mdl, filter, input, opts, recId, attachment, stats, mimeType } = await prepCrud.call(this, { model, req, reply, body, id, options, args: ['model', 'id'] })
|
|
5
|
-
opts._data = await getOneRecord(
|
|
5
|
+
opts._data = await getOneRecord.call(this, mdl, recId, filter, options)
|
|
6
6
|
const ret = await mdl.updateRecord(recId, input, opts)
|
|
7
7
|
if (attachment) ret.data._attachment = await mdl.findAttachment(id, { stats, mimeType })
|
|
8
8
|
return ret
|
package/lib/util.js
CHANGED
|
@@ -49,7 +49,7 @@ export async function getOneRecord (model, id, filter, options) {
|
|
|
49
49
|
const { cloneDeep } = this.app.lib._
|
|
50
50
|
let query = cloneDeep(filter.query)
|
|
51
51
|
query = { $and: [query ?? {}, { id }] }
|
|
52
|
-
const data = await model.findOneRecord({ query }, { dataOnly: true, noHook: true, noDynHook: true, noModelHook: true })
|
|
52
|
+
const data = await model.findOneRecord({ query }, { dataOnly: true, noHook: true, noDynHook: true, noModelHook: true, forceNoHidden: options.forceNoHidden })
|
|
53
53
|
if (!data && options.throwNotFound) throw this.error('_notFound')
|
|
54
54
|
return data
|
|
55
55
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED