@galadrim/galadmin 0.1.208 → 0.1.209
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/dist/api.js +7 -5
- package/dist/api.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/api.ts +7 -5
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -63,7 +63,7 @@ export default (db, config, user) => {
|
|
|
63
63
|
queryString += ")"
|
|
64
64
|
}
|
|
65
65
|
const limit = params.allRecords ? 999999 : parseInt(params.limit)
|
|
66
|
-
const query = params.customQuery || ("SELECT " + (params.selectExpression || "*") + " FROM ?? " + (params.join || "") + queryString + " " + (params.groupBy ? "GROUP BY " + params.groupBy : "") + (params.orderBy || params.primaryId ? " ORDER BY " + (params.orderBy || `${params.table}.${params.primaryId}`) : "") +
|
|
66
|
+
const query = params.customQuery || ("SELECT " + (params.selectExpression || "*") + " FROM ?? " + (params.join || "") + queryString + " " + (params.groupBy ? "GROUP BY " + params.groupBy : "") + (params.orderBy || params.primaryId ? " ORDER BY " + (params.orderBy || `${params.table}.${params.primaryId}`) : "") + " LIMIT ? OFFSET ?")
|
|
67
67
|
const queryParams = [params.table, limit, Math.max((params.page - 1) * limit, 0)]
|
|
68
68
|
const { err, rows } = await db.query(query, queryParams)
|
|
69
69
|
if (err) {
|
|
@@ -200,6 +200,8 @@ export default (db, config, user) => {
|
|
|
200
200
|
|
|
201
201
|
app.post('/records', async function (req, res, next) {
|
|
202
202
|
const view = config.views[req.body.viewIndex];
|
|
203
|
+
const isDesc = req.body.isDesc === null ? view.isDesc : req.body.isDesc
|
|
204
|
+
const orderBy = req.body.orderBy || (view.subviews && req.body.subviewIndex !== undefined ? view.subviews[req.body.subviewIndex]?.orderBy : null) || view.orderBy
|
|
203
205
|
const { rows: records, queryString, input, error } = await getRecords({
|
|
204
206
|
table: view.tableName,
|
|
205
207
|
page: req.body.page,
|
|
@@ -212,8 +214,7 @@ export default (db, config, user) => {
|
|
|
212
214
|
customQuery: view.customQuery,
|
|
213
215
|
join: view.join,
|
|
214
216
|
selectExpression: view.selectExpression,
|
|
215
|
-
orderBy: [
|
|
216
|
-
isDesc: req.body.isDesc === null ? view.isDesc : req.body.isDesc,
|
|
217
|
+
orderBy: [orderBy ? `${orderBy} ${isDesc ? "DESC" : "ASC"}` : null, view.primaryId].filter(x => x).join(", "),
|
|
217
218
|
primaryId: view.primaryId,
|
|
218
219
|
query: req.body.query,
|
|
219
220
|
groupBy: view.groupBy,
|
|
@@ -319,6 +320,8 @@ export default (db, config, user) => {
|
|
|
319
320
|
|
|
320
321
|
app.post('/recordsExport', async function (req, res) {
|
|
321
322
|
const view = config.views[req.body.viewIndex];
|
|
323
|
+
const orderBy = req.body.orderBy || view.orderBy;
|
|
324
|
+
const isDesc = req.body.isDesc === null ? view.isDesc : req.body.isDesc;
|
|
322
325
|
const { rows: records, error } = await getRecords({
|
|
323
326
|
table: view.tableName,
|
|
324
327
|
page: 1,
|
|
@@ -327,8 +330,7 @@ export default (db, config, user) => {
|
|
|
327
330
|
customQuery: view.customQuery,
|
|
328
331
|
join: view.join,
|
|
329
332
|
selectExpression: view.selectExpression,
|
|
330
|
-
orderBy:
|
|
331
|
-
isDesc: req.body.isDesc === null ? view.isDesc : req.body.isDesc,
|
|
333
|
+
orderBy: orderBy ? `${orderBy} ${isDesc ? "DESC" : "ASC"}` : null,
|
|
332
334
|
primaryId: view.primaryId,
|
|
333
335
|
query: req.body.query,
|
|
334
336
|
groupBy: view.groupBy,
|