@opengis/fastify-table 2.5.60 → 2.5.61
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA+BpD,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,QAAQ,EACR,MAAM,EACN,UAAU,EACV,QAAQ,EACR,UAAU,EACV,GAAG,EACH,EAAqB,GACtB,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB
|
|
1
|
+
{"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA+BpD,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,QAAQ,EACR,MAAM,EACN,UAAU,EACV,QAAQ,EACR,UAAU,EACV,GAAG,EACH,EAAqB,GACtB,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB;;;;;;UAyGA;AAED,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,gBA6d7C"}
|
|
@@ -45,11 +45,24 @@ export async function getTableColumnMeta({ table, template, column, selectName,
|
|
|
45
45
|
const searchQuerySelect = startsWith && key
|
|
46
46
|
? `id in ( with cc(id, text) as (${select}) select id from cc where (left(lower("text"),${key.length})=$1) )`
|
|
47
47
|
: `id in ( with cc(id, text) as (${select}) select id from cc where (lower("text") ~ $1) )`;
|
|
48
|
+
const counts = pg.queryCache
|
|
49
|
+
? await pg
|
|
50
|
+
.queryCache(`SELECT json_object_agg( (
|
|
51
|
+
SELECT
|
|
52
|
+
nspname
|
|
53
|
+
FROM
|
|
54
|
+
pg_namespace
|
|
55
|
+
WHERE
|
|
56
|
+
oid = relnamespace
|
|
57
|
+
) || '.' || relname, reltuples::bigint) FROM pg_class WHERE relkind = 'r'`)
|
|
58
|
+
.then((r) => r.rows[0].json_object_agg)
|
|
59
|
+
: {};
|
|
48
60
|
if (pg.pgType?.[dataTypeID]?.includes("[]")) {
|
|
49
61
|
const original = filtered
|
|
50
62
|
? `with c(id,text) as (select id, id as text from (select unnest(${column}) as id from ${tableName} t ${sqlTable})q group by id) select id, text from c`
|
|
51
63
|
: `with c(id,text) as (select id, id as text, count(*) from (select unnest(${column}) as id from ${tableName} t ${sqlTable})q group by id limit ${defaultLimit}) select * from c`;
|
|
52
64
|
return {
|
|
65
|
+
count: counts[tableName] || 0,
|
|
53
66
|
arr,
|
|
54
67
|
original,
|
|
55
68
|
searchQuery: select ? searchQuerySelect : searchQueryDefault,
|
|
@@ -60,6 +73,7 @@ export async function getTableColumnMeta({ table, template, column, selectName,
|
|
|
60
73
|
? `with c(id,text) as (select ${column} as id, ${column} as text from ${tableName} t ${sqlTable} group by ${column}) select id, text from c`
|
|
61
74
|
: `with c(id,text) as (select ${column} as id, ${column} as text, count(*) from ${tableName} t ${sqlTable} group by ${column} limit ${defaultLimit}) select * from c`;
|
|
62
75
|
return {
|
|
76
|
+
count: counts[tableName] || 0,
|
|
63
77
|
arr,
|
|
64
78
|
original,
|
|
65
79
|
searchQuery: select ? searchQuerySelect : searchQueryDefault,
|