@opengis/fastify-table 1.1.113 → 1.1.114

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.1.113",
3
+ "version": "1.1.114",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "main": "index.js",
@@ -73,11 +73,13 @@ export default async function update(req) {
73
73
  // delete old extra data
74
74
  await pgClients.client.query(`delete from ${schema[key].table} where ${schema[key].parent_id}=$1`, [objId]); // rewrite?
75
75
  // insert new extra data
76
- const extraRows = await Promise.all(body[key].map(async (row) => {
77
- const extraRes = await dataInsert({ table: schema[key].table, data: { ...row, [schema[key].parent_id]: objId }, uid });
78
- return extraRes?.rows?.[0];
79
- }));
80
- Object.assign(res.extra, { [key]: extraRows.filter((el) => el) });
76
+ if (Array.isArray(body[key]) && body[key]?.length) {
77
+ const extraRows = await Promise.all(body[key]?.map?.(async (row) => {
78
+ const extraRes = await dataInsert({ table: schema[key].table, data: { ...row, [schema[key].parent_id]: objId }, uid });
79
+ return extraRes?.rows?.[0];
80
+ }));
81
+ Object.assign(res.extra, { [key]: extraRows.filter((el) => el) });
82
+ }
81
83
  }));
82
84
  }
83
85