@opengis/bi
Version:
BI data visualization module
30 lines (23 loc) • 954 B
JavaScript
import { pgClients } from "@opengis/fastify-table/utils.js";
const maxLimit = 100;
/**
* Отримання списку наборів даних BI
*
* @method GET
* @summary Отримання списку наборів даних BI
* @priority 4
* @alias biDatasetList
* @type api
* @tag bi
* @errors 400,500
* @returns {Number} status Номер помилки
* @returns {String} error Опис помилки
* @returns {Object} rows Масив з колонками таблиці
*/
export default async function biDatasetList({ pg = pgClients.client, query = {} }) {
const limit = Math.min(maxLimit, +(query.limit || 20));
const offset = query.page && query.page > 0 ? (query.page - 1) * limit : 0;
const { rows = [] } = await pg.query(`select dataset_id as id, name, source_type as source, table_name as table, dashboard_list
from bi.dataset order by name limit ${limit} offset ${offset}`);
return { rows };
};