@opengis/fastify-table 1.3.17 → 1.3.18
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
|
@@ -25,6 +25,7 @@ export default async function dataAPI(req, reply, called) {
|
|
|
25
25
|
const hookData = await applyHook('preData', {
|
|
26
26
|
pg, table: params?.table, id: params?.id, user,
|
|
27
27
|
});
|
|
28
|
+
|
|
28
29
|
if (hookData?.message && hookData?.status) {
|
|
29
30
|
return { message: hookData?.message, status: hookData?.status };
|
|
30
31
|
}
|
|
@@ -49,7 +50,9 @@ export default async function dataAPI(req, reply, called) {
|
|
|
49
50
|
|
|
50
51
|
if (query.sql === '0') return loadTable;
|
|
51
52
|
|
|
52
|
-
if (!loadTable && !(tokenData?.table && pg.pk?.[tokenData?.table]) && !(called && pg.pk?.[params?.table])) {
|
|
53
|
+
if (!loadTable && !(tokenData?.table && pg.pk?.[tokenData?.table]) && !(called && pg.pk?.[params?.table])) {
|
|
54
|
+
return { message: 'template not found', status: 404 };
|
|
55
|
+
}
|
|
53
56
|
|
|
54
57
|
const id = tokenData?.id || hookData?.id || params?.id;
|
|
55
58
|
const { actions = [], query: accessQuery } = await getAccess({ table: tokenData?.table || hookData?.table || params.table, id, user }, pg) || {};
|
|
@@ -100,6 +103,7 @@ export default async function dataAPI(req, reply, called) {
|
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
const checkFilter = [query.filter, query.search, query.state, query.custom].filter((el) => el).length;
|
|
106
|
+
|
|
103
107
|
const fData = checkFilter ? await getFilterSQL({
|
|
104
108
|
pg,
|
|
105
109
|
table: loadTable ? params.table : table,
|
|
@@ -110,12 +114,14 @@ export default async function dataAPI(req, reply, called) {
|
|
|
110
114
|
uid,
|
|
111
115
|
json: 1,
|
|
112
116
|
}) : {};
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
|
|
118
|
+
timeArr.push(Date.now());
|
|
119
|
+
|
|
120
|
+
const keyQuery = query.key && (loadTable?.key || tokenData?.key) && !(tokenData?.id || hookData?.id || params.id) ? `${loadTable?.key || tokenData?.key}=$1` : null;
|
|
115
121
|
|
|
116
122
|
const limit = called ? (query.limit || 20) : Math.min(maxLimit, +(query.limit || 20));
|
|
117
123
|
|
|
118
|
-
const offset = query.page && query.page > 0 ? ` offset ${(query.page - 1) * limit}` : '';
|
|
124
|
+
const offset = query.page && query.page > 0 && !(tokenData?.id || hookData?.id || params.id) ? ` offset ${(query.page - 1) * limit}` : '';
|
|
119
125
|
// id, query, filter
|
|
120
126
|
const [orderColumn, orderDir] = (query.order || loadTable?.order || '').split(/[- ]/);
|
|
121
127
|
|