@opengis/fastify-table 1.4.63 → 1.4.64
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
|
@@ -182,11 +182,12 @@ export default async function dataAPI(req, reply, called) {
|
|
|
182
182
|
|
|
183
183
|
const offset = query.page && query.page > 0 && !objectId ? ` offset ${(query.page - 1) * limit}` : '';
|
|
184
184
|
// id, query, filter
|
|
185
|
-
const [orderColumn, orderDir] = (query.order || loadTable?.order || '').split(/[- ]/);
|
|
185
|
+
const [orderColumn, orderDir] = called && query.order ? [query.order] : (query.order || loadTable?.order || '').split(/[- ]/);
|
|
186
186
|
|
|
187
|
-
const order = query.order && columnList.includes(orderColumn) && orderColumn?.length
|
|
188
|
-
? `order by ${orderColumn} ${query.desc || orderDir === 'desc' ? 'desc' : ''} nulls last`
|
|
187
|
+
const order = query.order && (columnList.includes(orderColumn) && orderColumn?.length || called)
|
|
188
|
+
? `order by ${orderColumn} ${query.desc || orderDir === 'desc' ? 'desc' : ''} ${!called ? 'nulls last' : ''}`
|
|
189
189
|
: `order by ${(loadTable?.order || 'true::boolean')} nulls last`;
|
|
190
|
+
|
|
190
191
|
const search = loadTable?.meta?.search && query.search
|
|
191
192
|
? `(${loadTable?.meta?.search?.split(',')?.map(el => `${el} ilike '%${query.search.replace(/%/g, '\\%').replace(/'/g, "''")}%'`).join(' or ')})`
|
|
192
193
|
: null;
|