@opengis/fastify-table 1.1.140 → 1.1.141
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
|
@@ -7,7 +7,7 @@ export default async function getMeta(opt) {
|
|
|
7
7
|
const pg = opt?.pg || getPG({ name: 'client' });
|
|
8
8
|
const table = opt?.table || opt;
|
|
9
9
|
|
|
10
|
-
if (data[table]) return data[table];
|
|
10
|
+
if (data[pg.options.database]?.[table]) return data[pg.options.database][table];
|
|
11
11
|
|
|
12
12
|
if (!pg.tlist?.includes(table?.replace?.(/"/g, ''))) {
|
|
13
13
|
return { error: `${table} - not found`, status: 400 };
|
|
@@ -25,9 +25,23 @@ export default async function getMeta(opt) {
|
|
|
25
25
|
|
|
26
26
|
const geomAttr = fields.find((el) => pg.pgType?.[el.dataTypeID] === 'geometry')?.name; // change geometry text to geometry code
|
|
27
27
|
|
|
28
|
+
const dbColumns = await pg.query(`select json_object_agg(
|
|
29
|
+
attname,
|
|
30
|
+
json_build_object(
|
|
31
|
+
'title', pg_catalog.col_description(attrelid,attnum)
|
|
32
|
+
/*,'type', atttypid::regtype */
|
|
33
|
+
)
|
|
34
|
+
) from pg_catalog.pg_attribute a
|
|
35
|
+
where attrelid=$1::regclass and attnum>0`, [table]).then(el => el.rows?.[0]?.json_object_agg || {});
|
|
36
|
+
|
|
37
|
+
fields.forEach(el => Object.assign(el, { ...dbColumns[el.name] || {} }));
|
|
38
|
+
|
|
28
39
|
const res = {
|
|
29
40
|
pk, columns: fields, geom: geomAttr, view: pg.relkinds?.[table] === 'v',
|
|
30
41
|
};
|
|
31
|
-
data[
|
|
42
|
+
if (!data[pg.options.database]) {
|
|
43
|
+
data[pg.options.database] = {};
|
|
44
|
+
}
|
|
45
|
+
data[pg.options.database][table] = res;
|
|
32
46
|
return res;
|
|
33
47
|
}
|