@opengis/fastify-table 1.1.87 → 1.1.89
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
|
@@ -56,7 +56,14 @@ export default async function execMigrations(opt) {
|
|
|
56
56
|
try {
|
|
57
57
|
const pg = opt?.pg || getPG({ name: 'client' });
|
|
58
58
|
const rootDir = getCallerDir();
|
|
59
|
-
const
|
|
59
|
+
const subdir = () => {
|
|
60
|
+
if (rootDir.endsWith('plugins')) {
|
|
61
|
+
return '../..';
|
|
62
|
+
} if (path.basename(rootDir) === 'server') {
|
|
63
|
+
return '..';
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const dir = path.join(rootDir.replace(/\\/g, '/').replace(/^file:\/\/\//, ''), subdir() || '', 'server/migrations');
|
|
60
67
|
|
|
61
68
|
console.log('migrations start', dir, Date.now() - time);
|
|
62
69
|
const exists = fs.existsSync(dir);
|
|
@@ -98,7 +98,7 @@ export default async function dataAPI(req) {
|
|
|
98
98
|
${query.id || query.key ? '*' : sqlColumns || cols || '*'}
|
|
99
99
|
${metaCols}
|
|
100
100
|
${cardColumns}
|
|
101
|
-
from (select * from ${table} where ${where.join(' and ') || 'true'} ${order}) t
|
|
101
|
+
from (select * from ${table} where ${sqlTable ? 'true' : (where.join(' and ') || 'true')} ${order}) t
|
|
102
102
|
${sqlTable}
|
|
103
103
|
${cardSqlTable}
|
|
104
104
|
where ${where.join(' and ') || 'true'}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
config, getPG, getTemplate, getSelectMeta,
|
|
3
3
|
} from '../../../../utils.js';
|
|
4
4
|
|
|
5
|
-
const limit =
|
|
5
|
+
const limit = 50;
|
|
6
6
|
const headers = {
|
|
7
7
|
'Access-Control-Allow-Origin': '*',
|
|
8
8
|
'Access-Control-Allow-Methods': 'GET',
|
|
@@ -37,7 +37,7 @@ 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
|
|
40
|
+
if (meta?.minLength && query.key && query.key.length < meta?.minLength) {
|
|
41
41
|
return { message: `min length: ${meta.minLength}` };
|
|
42
42
|
}
|
|
43
43
|
const pg = meta?.db ? getPG(meta.db) : pg1;
|
|
@@ -65,7 +65,7 @@ export default async function suggest(req) {
|
|
|
65
65
|
|
|
66
66
|
const val = query.val ? ` ${meta.pk}=any('{${query.val.replace(/'/g, "''")}}')` : '';
|
|
67
67
|
const where = [search, val, `${meta.pk} is not null`].filter((el) => el).join(' and ') || 'true';
|
|
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 ||
|
|
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 || limit}`.replace(/{{uid}}/g, user?.uid || '0');
|
|
69
69
|
if (query.sql && config.local) return sqlSuggest;
|
|
70
70
|
|
|
71
71
|
// query
|