dobo 2.40.0 → 2.40.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.
@@ -292,9 +292,10 @@ export async function handleAttachmentUpload (id, trigger, options = {}) {
292
292
  * @returns {Promise<void>}
293
293
  * @param {Array<Object>} records - The records to get attachments for.
294
294
  */
295
- export async function getAttachments (records = []) {
295
+ export async function getAttachments (records = [], options = {}) {
296
+ options.keys = ['url', 'mimeType', 'fileName']
296
297
  for (const rec of records) {
297
- rec._attachments = await this.listAttachment({ id: rec.id })
298
+ rec._attachments = await this.listAttachment({ id: rec.id }, options)
298
299
  }
299
300
  }
300
301
 
@@ -4,14 +4,14 @@ const action = 'listAttachment'
4
4
  async function listAttachment (...args) {
5
5
  if (!this.options.attachment || !this.app.waibu) return []
6
6
  if (args.length === 0) return this.action(action, ...args)
7
- const [params = {}, opts = {}] = args
8
- const { map, kebabCase } = this.app.lib._
7
+ const [params = {}, options = {}] = args
8
+ const { map, kebabCase, pick } = this.app.lib._
9
9
  const { importPkg } = this.app.bajo
10
10
  const mime = await importPkg('waibu:mime')
11
11
  const { fastGlob } = this.app.lib
12
12
 
13
13
  const { id = '*', field = '*', file = '*', type } = params
14
- const { uriEncoded = true } = opts
14
+ let { uriEncoded = true, keys = [] } = options
15
15
  const root = `${this.app.getPluginDataDir('dobo')}/attachment`
16
16
  let pattern = `${root}/${this.name}/${id}/${field}/${file}`
17
17
  if (type === 'image') pattern += '.{jpg,jpeg,gif,png,webp,avif,svg}'
@@ -33,7 +33,8 @@ async function listAttachment (...args) {
33
33
  const [, _model, _id, _field, _file] = fullPath.split('/')
34
34
  row.url = routePath(`dobo:/attachment/${kebabCase(_model)}/${_id}/${_field}/${_file}`)
35
35
  }
36
- return row
36
+ if (keys.length === 0) keys = Object.keys(row)
37
+ return pick(row, keys)
37
38
  })
38
39
  }
39
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dobo",
3
- "version": "2.40.0",
3
+ "version": "2.40.1",
4
4
  "description": "DBMS for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  - [2.40.0] Add `helper.getAttachments()`
7
7
  - [2.40.0] Auto attach `_attachments` if `options.attachments` is true
8
+ - [2.40.1] Bug fix on returned `_attachments`
8
9
 
9
10
  ## 2026-10-17
10
11