waibu-db 2.12.1 → 2.12.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.
- package/index.js +1 -2
- package/lib/crud/add-handler.js +1 -1
- package/lib/crud/delete-handler.js +2 -2
- package/lib/crud/details-handler.js +1 -1
- package/lib/crud/edit-handler.js +1 -1
- package/lib/crud/export-handler.js +1 -1
- package/lib/crud/list-handler.js +1 -1
- package/lib/method/count-record.js +1 -1
- package/lib/method/create-aggregate.js +1 -1
- package/lib/method/create-histogram.js +1 -1
- package/lib/method/find-all-record.js +1 -1
- package/lib/method/find-one-record.js +1 -1
- package/lib/method/find-record.js +1 -1
- package/lib/method/get-record.js +1 -1
- package/lib/method/get-schema-ext.js +3 -0
- package/lib/method/remove-record.js +1 -1
- package/lib/method/update-record.js +1 -1
- package/lib/util.js +1 -2
- package/package.json +1 -1
- package/wiki/CHANGES.md +6 -1
package/index.js
CHANGED
|
@@ -157,10 +157,9 @@ async function factory (pkgName) {
|
|
|
157
157
|
const q = query ?? set({}, field, { $in })
|
|
158
158
|
const options = {
|
|
159
159
|
dataOnly: true,
|
|
160
|
-
limit: -1,
|
|
161
160
|
query: q
|
|
162
161
|
}
|
|
163
|
-
return await this.
|
|
162
|
+
return await this.findAllRecord({ model, req, options })
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
formatRecord = async ({ data, req, schema, options = {} }) => {
|
package/lib/crud/add-handler.js
CHANGED
|
@@ -6,7 +6,7 @@ async function addHandler ({ req, reply, model, params = {}, template, addOnsHan
|
|
|
6
6
|
const { pick, map, merge, omit } = this.app.lib._
|
|
7
7
|
const opts = merge({}, options.modelOpts)
|
|
8
8
|
model = pascalCase(model ?? req.params.model)
|
|
9
|
-
const { schema } = await getSchemaExt(model, 'add', merge({}, { params }, options))
|
|
9
|
+
const { schema } = await getSchemaExt(model, 'add', merge({ args: [req] }, { params }, options))
|
|
10
10
|
if (schema.disabled.includes('create')) return await reply.view(templateDisabled, { action: 'add' })
|
|
11
11
|
// req.query.attachment = true
|
|
12
12
|
opts.fields = schema.view.fields
|
|
@@ -5,14 +5,14 @@ async function deleteHandler ({ req, reply, model, params = {}, templateDisabled
|
|
|
5
5
|
const { reduce, merge } = this.app.lib._
|
|
6
6
|
const opts = merge({}, options.modelOpts)
|
|
7
7
|
model = pascalCase(model ?? req.params.model)
|
|
8
|
-
const { schema } = await getSchemaExt(model, '
|
|
8
|
+
const { schema } = await getSchemaExt(model, 'delete', merge({ args: [req] }, { params }, options))
|
|
9
9
|
if (schema.disabled.includes('remove')) return await reply.view(templateDisabled, { action: 'delete' })
|
|
10
10
|
opts.fields = schema.view.fields
|
|
11
11
|
delete req.query.query
|
|
12
12
|
const ids = (req.body.ids ?? '').split(',')
|
|
13
13
|
if (ids.length > 0) {
|
|
14
14
|
const result = []
|
|
15
|
-
opts.noResult = true
|
|
15
|
+
// opts.noResult = true
|
|
16
16
|
opts.noFlash = true
|
|
17
17
|
for (const id of ids) {
|
|
18
18
|
try {
|
|
@@ -6,7 +6,7 @@ async function detailsHandler ({ req, reply, model, params = {}, id, template, a
|
|
|
6
6
|
const { merge, isEmpty } = this.app.lib._
|
|
7
7
|
const opts = merge({ refs: '*' }, options.modelOpts)
|
|
8
8
|
model = pascalCase(model ?? req.params.model)
|
|
9
|
-
const { schema } = await getSchemaExt(model, 'details', merge({}, { params }, options))
|
|
9
|
+
const { schema } = await getSchemaExt(model, 'details', merge({ args: [req] }, { params }, options))
|
|
10
10
|
if (schema.disabled.includes('get')) return await reply.view(templateDisabled, { action: 'details' })
|
|
11
11
|
// req.query.attachment = true
|
|
12
12
|
opts.fields = schema.view.fields
|
package/lib/crud/edit-handler.js
CHANGED
|
@@ -13,7 +13,7 @@ async function editHandler ({ req, reply, model, id, params = {}, template, addO
|
|
|
13
13
|
let resp
|
|
14
14
|
let form
|
|
15
15
|
model = pascalCase(model ?? req.params.model)
|
|
16
|
-
const { schema } = await getSchemaExt(model, 'edit', merge({}, { params }, options))
|
|
16
|
+
const { schema } = await getSchemaExt(model, 'edit', merge({ args: [req] }, { params }, options))
|
|
17
17
|
if (schema.disabled.includes('update')) return await reply.view(templateDisabled, { action: 'edit' })
|
|
18
18
|
// req.query.attachment = true
|
|
19
19
|
opts.fields = schema.view.fields
|
|
@@ -9,7 +9,7 @@ async function exportHandler ({ req, reply, model, params = {}, templateDisabled
|
|
|
9
9
|
const { buildUrl } = this.app.waibuMpa
|
|
10
10
|
const { pushDownload } = getPlugin('sumba')
|
|
11
11
|
model = pascalCase(model ?? req.params.model)
|
|
12
|
-
const { schema } = await getSchemaExt(model, 'add', merge({}, { params }, options))
|
|
12
|
+
const { schema } = await getSchemaExt(model, 'add', merge({ args: [req] }, { params }, options))
|
|
13
13
|
if (schema.disabled.includes('find')) return await reply.view(templateDisabled, { action: 'list' })
|
|
14
14
|
const data = await prepCrud.call(getPlugin('waibuDb'), { model, req, reply, args: ['model'] })
|
|
15
15
|
data.opts = omit(data.opts, ['req', 'reply'])
|
package/lib/crud/list-handler.js
CHANGED
|
@@ -6,7 +6,7 @@ async function listHandler ({ req, reply, model, template, params = {}, addOnsHa
|
|
|
6
6
|
|
|
7
7
|
const opts = merge({}, { count: true, refs: '*' }, options.modelOpts)
|
|
8
8
|
model = pascalCase(model ?? req.params.model)
|
|
9
|
-
const { schema } = await getSchemaExt(model, 'list', merge({}, { params }, options))
|
|
9
|
+
const { schema } = await getSchemaExt(model, 'list', merge({ args: [req] }, { params }, options))
|
|
10
10
|
if (schema.disabled.includes('find')) return await reply.view(templateDisabled, { action: 'list' })
|
|
11
11
|
for (const key of ['sort', 'limit', 'fields']) {
|
|
12
12
|
const sessKey = `wdb${model}${upperFirst(key)}`
|
|
@@ -4,7 +4,7 @@ async function countRecord ({ model, req, reply, options = {}, transaction } = {
|
|
|
4
4
|
const { model: mdl, opts, filter } = await prepCrud.call(this, { model, req, reply, options, args: ['model'], transaction })
|
|
5
5
|
|
|
6
6
|
async function handler (trx) {
|
|
7
|
-
opts.trx
|
|
7
|
+
if (opts.trx === true) opts.trx = trx
|
|
8
8
|
return await mdl.countRecord(filter, opts)
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -9,7 +9,7 @@ async function createAggregate ({ model, req, reply, options = {}, transaction }
|
|
|
9
9
|
params.aggregates = params.aggregates ?? ['count']
|
|
10
10
|
|
|
11
11
|
async function handler (trx) {
|
|
12
|
-
opts.trx
|
|
12
|
+
if (opts.trx === true) opts.trx = trx
|
|
13
13
|
return await mdl.createAggregate(filter, params, opts)
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ async function createHistogram ({ model, req, reply, options = {}, transaction }
|
|
|
9
9
|
params.aggregates = params.aggregates ?? ['count']
|
|
10
10
|
|
|
11
11
|
async function handler (trx) {
|
|
12
|
-
opts.trx
|
|
12
|
+
if (opts.trx === true) opts.trx = trx
|
|
13
13
|
return await mdl.createHistogram(filter, params, opts)
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -4,7 +4,7 @@ async function findAllRecord ({ model, req, reply, options = {}, transaction } =
|
|
|
4
4
|
const { model: mdl, opts, filter, attachment, stats, mimeType } = await prepCrud.call(this, { model, req, reply, options, args: ['model'], transaction })
|
|
5
5
|
|
|
6
6
|
async function handler (trx) {
|
|
7
|
-
opts.trx
|
|
7
|
+
if (opts.trx === true) opts.trx = trx
|
|
8
8
|
const ret = await mdl.findAllRecord(filter, opts)
|
|
9
9
|
if (attachment) {
|
|
10
10
|
for (const d of ret.data) {
|
|
@@ -4,7 +4,7 @@ async function findOneRecord ({ model, req, reply, options = {}, transaction } =
|
|
|
4
4
|
const { model: mdl, opts, filter, attachment, stats, mimeType } = await prepCrud.call(this, { model, req, reply, options, args: ['model'], transaction })
|
|
5
5
|
|
|
6
6
|
async function handler (trx) {
|
|
7
|
-
opts.trx
|
|
7
|
+
if (opts.trx === true) opts.trx = trx
|
|
8
8
|
const ret = await mdl.findOneRecord(filter, opts)
|
|
9
9
|
if (attachment) ret.data._attachment = await mdl.findAttachment(ret.data.id, { stats, mimeType })
|
|
10
10
|
return ret
|
|
@@ -4,7 +4,7 @@ async function findRecord ({ model, req, reply, options = {}, transaction } = {}
|
|
|
4
4
|
const { model: mdl, opts, filter, attachment, stats, mimeType } = await prepCrud.call(this, { model, req, reply, options, args: ['model'], transaction })
|
|
5
5
|
|
|
6
6
|
async function handler (trx) {
|
|
7
|
-
opts.trx
|
|
7
|
+
if (opts.trx === true) opts.trx = trx
|
|
8
8
|
const ret = await mdl.findRecord(filter, opts)
|
|
9
9
|
if (attachment) {
|
|
10
10
|
for (const d of ret.data) {
|
package/lib/method/get-record.js
CHANGED
|
@@ -5,7 +5,7 @@ async function getRecord ({ model, req, reply, id, options = {}, transaction } =
|
|
|
5
5
|
const me = this
|
|
6
6
|
|
|
7
7
|
async function handler (trx) {
|
|
8
|
-
opts.trx
|
|
8
|
+
if (opts.trx === true) 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
11
|
return data
|
|
@@ -165,6 +165,9 @@ const handler = {
|
|
|
165
165
|
},
|
|
166
166
|
edit: async function (schema, ext, options) {
|
|
167
167
|
applyLayout.call(this, 'edit', schema, ext, options)
|
|
168
|
+
},
|
|
169
|
+
delete: async function (schema, ext, options) {
|
|
170
|
+
applyLayout.call(this, 'delete', schema, ext, options)
|
|
168
171
|
}
|
|
169
172
|
}
|
|
170
173
|
|
|
@@ -5,7 +5,7 @@ async function removeRecord ({ model, req, reply, id, options = {}, transaction
|
|
|
5
5
|
const me = this
|
|
6
6
|
|
|
7
7
|
async function handler (trx) {
|
|
8
|
-
opts.trx
|
|
8
|
+
if (opts.trx === true) opts.trx = trx
|
|
9
9
|
const resp = await getOneRecord.call(me, mdl, recId, filter, opts)
|
|
10
10
|
opts._data = resp.data
|
|
11
11
|
return await mdl.removeRecord(recId, opts)
|
|
@@ -5,7 +5,7 @@ async function updateRecord ({ model, req, reply, id, body, options = {}, transa
|
|
|
5
5
|
const me = this
|
|
6
6
|
|
|
7
7
|
async function handler (trx) {
|
|
8
|
-
opts.trx
|
|
8
|
+
if (opts.trx === true) opts.trx = trx
|
|
9
9
|
const resp = await getOneRecord.call(me, mdl, recId, filter, opts)
|
|
10
10
|
opts._data = resp.data
|
|
11
11
|
const ret = await mdl.updateRecord(recId, input, opts)
|
package/lib/util.js
CHANGED
|
@@ -14,7 +14,6 @@ export async function prepCrud ({ model, body, id, req, reply, transaction, opti
|
|
|
14
14
|
if (opts.suppressError === true) opts.suppressError = actions
|
|
15
15
|
else if (isString(opts.suppressError)) opts.suppressError = [opts.suppressError]
|
|
16
16
|
else opts.suppressError = opts.suppressError ?? []
|
|
17
|
-
opts.trx = options.trx
|
|
18
17
|
const params = this.getParams(req, ...args)
|
|
19
18
|
for (const k of ['count', 'fields']) {
|
|
20
19
|
opts[k] = opts[k] ?? params[k]
|
|
@@ -23,7 +22,7 @@ export async function prepCrud ({ model, body, id, req, reply, transaction, opti
|
|
|
23
22
|
opts.dataOnly = opts.dataOnly ?? false
|
|
24
23
|
opts.req = req
|
|
25
24
|
opts.reply = reply
|
|
26
|
-
opts.trx = opts.trx
|
|
25
|
+
opts.trx = opts.trx ?? options.trx ?? transaction ?? true
|
|
27
26
|
|
|
28
27
|
let { attachment, stats, mimeType } = opts
|
|
29
28
|
attachment = attachment ?? req.query.attachment
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-03-30
|
|
4
|
+
|
|
5
|
+
- [2.12.3] Bug fix in transaction supports
|
|
6
|
+
- [2.12.4] Bug fix in ```options.limit```, removed due to use ```findAllRecords()```
|
|
7
|
+
|
|
3
8
|
## 2026-03-27
|
|
4
9
|
|
|
5
10
|
- [2.12.1] Bug fix in all ```view.formatter``` & ```view.valueFormatter```
|
|
6
|
-
- [2.12.
|
|
11
|
+
- [2.12.2] Bug fix in ```wdb-form``` & ```wdb-table``` widgets, now correctly use value from formatter if provided
|
|
7
12
|
|
|
8
13
|
## 2026-03-26
|
|
9
14
|
|