@opengis/fastify-table 1.3.33 → 1.3.35
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
|
@@ -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) =>
|
|
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 = {};
|
|
@@ -64,7 +64,7 @@ export default async function tableAPI(req) {
|
|
|
64
64
|
|
|
65
65
|
if (query?.sql === '1') return q;
|
|
66
66
|
|
|
67
|
-
const data = await pg.query(q, [id]).then(el => el.rows[0]);
|
|
67
|
+
const data = await pg.query(q.replace(/{{uid}}/, user?.uid), [id]).then(el => el.rows[0]);
|
|
68
68
|
if (!data) return { message: 'not found', status: 404 };
|
|
69
69
|
|
|
70
70
|
Object.keys(schema).filter(key => schema[key]?.type === 'DataTable').forEach(key => {
|
|
@@ -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) =>
|
|
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) => {
|