enhance: add endpoint to fetch query data by query store id
This commit is contained in:
parent
fdf67d4763
commit
16f6846d89
2 changed files with 31 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
import { Request, Response } from "express";
|
||||
import DynamicQueryBuilder from "../../../helpers/dynamicQueryBuilder";
|
||||
import { dataSource } from "../../../data-source";
|
||||
import QueryStoreService from "../../../service/configuration/queryStoreService";
|
||||
|
||||
/**
|
||||
* @description get all table metas
|
||||
|
@ -43,3 +44,23 @@ export async function executeQuery(req: Request, res: Response): Promise<any> {
|
|||
|
||||
res.json(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description execute Query by StoreId
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function executeQueryByStoreId(req: Request, res: Response): Promise<any> {
|
||||
let offset = parseInt((req.query.offset as string) ?? "0");
|
||||
let count = parseInt((req.query.count as string) ?? "25");
|
||||
let noLimit = req.query.noLimit === "true";
|
||||
const storeId = req.params.storeId;
|
||||
|
||||
let queryStore = await QueryStoreService.getById(storeId);
|
||||
let query = queryStore.query.startsWith("{") ? JSON.parse(queryStore.query) : queryStore.query;
|
||||
|
||||
let result = await DynamicQueryBuilder.executeQuery({ query, offset, count, noLimit });
|
||||
|
||||
res.json(result);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue