@opengis/fastify-table 1.3.32 → 1.3.34

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.3.32",
3
+ "version": "1.3.34",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -84,7 +84,7 @@ export default async function insert(req) {
84
84
  });
85
85
  // form DataTable
86
86
  // to do: rewrite as single transaction
87
- const extraKeys = Object.keys(schema || {})?.filter((key) => schema?.[key]?.type === 'DataTable' && schema?.[key]?.table && schema?.[key]?.parent_id && body[key]?.length);
87
+ const extraKeys = Object.keys(schema || {})?.filter((key) => body[key]?.length && Array.isArray(body[key]) && schema?.[key]?.table && schema?.[key]?.parent_id);
88
88
  const pkey = res?.rows?.[0]?.[loadTemplate?.key || pg.pk?.[loadTemplate?.table || table]];
89
89
  if (extraKeys?.length) {
90
90
  res.extra = {};
@@ -90,7 +90,7 @@ export default async function update(req) {
90
90
  });
91
91
 
92
92
  // form DataTable
93
- const extraKeys = Object.keys(schema || {})?.filter((key) => schema?.[key]?.type === 'DataTable' && schema?.[key]?.table && schema?.[key]?.parent_id /* && body[key].length */);
93
+ const extraKeys = Object.keys(schema || {})?.filter((key) => Array.isArray(body[key]) && schema?.[key]?.table && schema?.[key]?.parent_id /* && body[key].length */);
94
94
  if (extraKeys?.length) {
95
95
  res.extra = {};
96
96
  await Promise.all(extraKeys?.map(async (key) => {
@@ -187,7 +187,7 @@ export default async function dataAPI(req, reply, called) {
187
187
 
188
188
  const counts = keyQuery || tokenData?.id || hookData?.id || params.id
189
189
  ? { total: rows.length, filtered: rows.length }
190
- : await pg.queryCache?.(qCount, { table: loadTable?.table || tokenData?.table, time: 5 * 60 }).then(el => el?.rows[0] || {});
190
+ : await pg.queryCache?.(qCount, { table: loadTable?.table || tokenData?.table, time: 5 }).then(el => el?.rows[0] || {});
191
191
 
192
192
  timeArr.push(Date.now())
193
193
  const { total, filtered } = counts || {};