@opengis/fastify-table 1.1.133 → 1.1.134
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
|
@@ -62,12 +62,13 @@ export default async function insert(req) {
|
|
|
62
62
|
table, token: params?.table, body, payload: res, user,
|
|
63
63
|
});
|
|
64
64
|
// form DataTable
|
|
65
|
+
// to do: rewrite as single transaction
|
|
65
66
|
const extraKeys = Object.keys(schema || {})?.filter((key) => schema?.[key]?.type === 'DataTable' && schema?.[key]?.table && schema?.[key]?.parent_id && body[key]?.length);
|
|
66
|
-
|
|
67
|
+
const pkey = res?.rows?.[0]?.[loadTemplate?.key || pgClients.client?.pk?.[loadTemplate?.table || table]];
|
|
67
68
|
if (extraKeys?.length) {
|
|
68
69
|
res.extra = {};
|
|
69
70
|
await Promise.all(extraKeys?.map(async (key) => {
|
|
70
|
-
const objId = body[schema[key].parent_id] || req.body?.id || res?.rows?.[0]?.[schema[key].parent_id];
|
|
71
|
+
const objId = body[schema[key].parent_id] || req.body?.id || res?.rows?.[0]?.[schema[key].parent_id] || pkey;
|
|
71
72
|
const extraRows = await Promise.all(body[key].map(async (row) => {
|
|
72
73
|
const extraRes = await dataInsert({
|
|
73
74
|
table: schema[key].table, data: { ...row, [schema[key].parent_id]: objId }, uid: user?.uid,
|