@opengis/fastify-table 1.1.81 → 1.1.82

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.1.81",
3
+ "version": "1.1.82",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "main": "index.js",
@@ -46,7 +46,8 @@ export default async function getSelectMeta({ name, pg = pgClients.client, nocac
46
46
  const searchQuery = `(${searchColumn.split(',').map((el) => `lower("${el}") ~ $1 `).join(' or ')})`;
47
47
  // console.log(dataOrigin1.fields.map((el) => el.name).join(','));
48
48
  const data = {
49
-
49
+ minLength: cls.minLength,
50
+ limit: cls.limit,
50
51
  type: type.join(','),
51
52
  cols: cols.join(','),
52
53
  originalCols: originalCols.join(','),
@@ -2,7 +2,7 @@ import {
2
2
  config, getPG, getTemplate, getSelectMeta,
3
3
  } from '../../../../utils.js';
4
4
 
5
- const limit = 50;
5
+ const limit = 20;
6
6
  const headers = {
7
7
  'Access-Control-Allow-Origin': '*',
8
8
  'Access-Control-Allow-Methods': 'GET',
@@ -37,6 +37,9 @@ export default async function suggest(req) {
37
37
  searchQuery: '(lower("text") ~ $1 )',
38
38
  }
39
39
  : await getSelectMeta({ name: selectName, nocache: query?.nocache });
40
+ if (meta.minLength && query.key && query.key.length < meta.minLength) {
41
+ return { message: `min length: ${meta.minLength}` };
42
+ }
40
43
  const pg = meta?.db ? getPG(meta.db) : pg1;
41
44
  if (!meta) return { headers, status: 404, message: 'Not found query select ' };
42
45
  if (query.meta) return meta;
@@ -62,7 +65,7 @@ export default async function suggest(req) {
62
65
 
63
66
  const val = query.val ? ` ${meta.pk}=any('{${query.val.replace(/'/g, "''")}}')` : '';
64
67
  const where = [search, val, `${meta.pk} is not null`].filter((el) => el).join(' and ') || 'true';
65
- const sqlSuggest = `with c(id,text) as ( ${meta.original.replace(/{{parent}}/gi, parent)} where ${where} order by 2) select * from c `.replace(/{{uid}}/g, user?.uid || '0');
68
+ const sqlSuggest = `with c(id,text) as ( ${meta.original.replace(/{{parent}}/gi, parent)} where ${where} order by 2) select * from c limit ${meta.limit || 20}`.replace(/{{uid}}/g, user?.uid || '0');
66
69
  if (query.sql && config.local) return sqlSuggest;
67
70
 
68
71
  // query