waibu-db 2.4.0 → 2.6.0

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.
@@ -6,7 +6,7 @@ async function btnBack () {
6
6
  return class WdbBtnBack extends WdbBase {
7
7
  build = async () => {
8
8
  const { isEmpty } = this.app.lib._
9
- const { attrToArray } = this.app.waibuMpa
9
+ const { attrToArray } = this.app.waibu
10
10
  const { req } = this.component
11
11
  this.params.noTag = true
12
12
  if (isEmpty(this.params.attr.content)) this.params.attr.content = req.t('back')
@@ -6,7 +6,7 @@ async function form () {
6
6
  return class WdbForm extends WdbBase {
7
7
  build = async () => {
8
8
  const { get, find, filter, forOwn, isEmpty } = this.app.lib._
9
- const { base64JsonEncode } = this.app.waibuMpa
9
+ const { base64JsonEncode } = this.app.waibu
10
10
  const schema = get(this, 'component.locals.schema', {})
11
11
  const body = []
12
12
  const xModels = get(schema, 'view.x.model', [])
@@ -17,7 +17,8 @@ async function pagination () {
17
17
  return class WdbPagination extends WdbBase {
18
18
  build = async () => {
19
19
  const { req } = this.component
20
- const { attrToObject, paginationLayout, groupAttrs } = this.app.waibuMpa
20
+ const { paginationLayout, groupAttrs } = this.app.waibuMpa
21
+ const { attrToObject } = this.app.waibu
21
22
  const { get, isNumber } = this.app.lib._
22
23
  const schema = get(this, 'component.locals.schema', {})
23
24
  if (schema.view.disabled.includes('find')) {
@@ -7,7 +7,8 @@ async function recsInfo () {
7
7
  return class WdbRecsInfo extends WdbBase {
8
8
  build = async () => {
9
9
  const { req } = this.component
10
- const { attrToObject, groupAttrs, attrToArray } = this.app.waibuMpa
10
+ const { groupAttrs } = this.app.waibuMpa
11
+ const { attrToObject, attrToArray } = this.app.waibu
11
12
  const { get, isEmpty, omit, merge } = this.app.lib._
12
13
  const schema = get(this, 'component.locals.schema', {})
13
14
  if (schema.view.disabled.includes('find')) {
@@ -35,9 +35,9 @@ async function table () {
35
35
 
36
36
  build = async () => {
37
37
  const { req } = this.component
38
- const { escape } = this.app.waibu
38
+ const { escape, attrToArray } = this.app.waibu
39
39
  const { formatRecord } = this.app.waibuDb
40
- const { attrToArray, groupAttrs } = this.app.waibuMpa
40
+ const { groupAttrs } = this.app.waibuMpa
41
41
  const { get, omit, set, find, isEmpty, without, merge } = this.app.lib._
42
42
  const group = groupAttrs(this.params.attr, ['body', 'head', 'foot'])
43
43
  this.params.attr = group._
package/index.js CHANGED
@@ -8,6 +8,7 @@ import getSchemaExt from './lib/method/get-schema-ext.js'
8
8
  import getRecord from './lib/method/get-record.js'
9
9
  import removeRecord from './lib/method/remove-record.js'
10
10
  import updateRecord from './lib/method/update-record.js'
11
+ import findAllRecord from './lib/method/find-all-record.js'
11
12
 
12
13
  /**
13
14
  * Plugin factory
@@ -62,7 +63,8 @@ async function factory (pkgName) {
62
63
  'getSchemaExt',
63
64
  'getRecord',
64
65
  'removeRecord',
65
- 'updateRecord'
66
+ 'updateRecord',
67
+ 'findAllRecord'
66
68
  ])
67
69
  }
68
70
 
@@ -214,6 +216,7 @@ async function factory (pkgName) {
214
216
  createRecord = createRecord
215
217
  findOneRecord = findOneRecord
216
218
  findRecord = findRecord
219
+ findAllRecord = findAllRecord
217
220
  getSchemaExt = getSchemaExt
218
221
  getRecord = getRecord
219
222
  removeRecord = removeRecord
@@ -1,6 +1,6 @@
1
1
  async function addOnsHandler ({ req, reply, data, schema, options = {} }) {
2
2
  const { escape } = this.app.waibu
3
- const { base64JsonEncode } = this.app.waibuMpa
3
+ const { base64JsonEncode } = this.app.waibu
4
4
  const { createAggregate } = this.app.waibuDb
5
5
  const { get, map, pick, pullAt } = this.app.lib._
6
6
  const opts = map(get(schema, 'view.stat.aggregate', []), item => {
@@ -0,0 +1,14 @@
1
+ import { prepCrud } from '../util.js'
2
+
3
+ async function findAllRecord ({ model, req, reply, options = {} }) {
4
+ const { model: mdl, opts, filter, attachment, stats, mimeType } = await prepCrud.call(this, { model, req, reply, options, args: ['model'] })
5
+ const ret = await mdl.findAllRecord(filter, opts)
6
+ if (attachment) {
7
+ for (const d of ret.data) {
8
+ d._attachment = await mdl.findAttachment(d.id, { stats, mimeType })
9
+ }
10
+ }
11
+ return ret
12
+ }
13
+
14
+ export default findAllRecord
@@ -112,11 +112,11 @@ function applyLayout (action, schema, ext) {
112
112
  } else {
113
113
  if (prop.type === 'boolean') {
114
114
  result.component = 'form-select'
115
- result.attr.options = 'false|No true|Yes'
115
+ result.attr.options = 'false:no true:yes'
116
116
  }
117
117
  if (prop.values) {
118
118
  result.component = 'form-select'
119
- result.attr.options = prop.values.join(' ')
119
+ result.attr.options = prop.values.map(item => `${item.value}:${item.text}`).join(' ')
120
120
  }
121
121
  if (['string', 'text'].includes(prop.type) && prop.maxLength) set(result, 'attr.maxlength', prop.maxLength)
122
122
  if (readonly.includes(f)) result.component = 'form-plaintext'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-02-18
4
+
5
+ - [2.6.0] Update attribute functions from ```waibu```
6
+ - [2.6.0] Bug fix on ```getSchemaExt()```'s ```applyLayout()```
7
+
8
+ ## 2026-02-15
9
+
10
+ - [2.5.0] Add ```findAllRecord()```
11
+
3
12
  ## 2026-02-08
4
13
 
5
14
  - [2.4.0] Add ```timeZone``` options in ```formatRow()```