mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 06:06:01 +00:00
table grid display, SQL for browse table is generated on FE
This commit is contained in:
20
packages/datalib/src/TableGridDisplay.ts
Normal file
20
packages/datalib/src/TableGridDisplay.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import GridDisplay from "./GridDisplay";
|
||||
import { Select } from "@dbgate/sqltree";
|
||||
import { TableInfo, EngineDriver } from "@dbgate/types";
|
||||
|
||||
export default class TableGridDisplay extends GridDisplay {
|
||||
constructor(public table: TableInfo, public driver: EngineDriver) {
|
||||
super();
|
||||
}
|
||||
|
||||
getPageQuery(offset: number, count: number) {
|
||||
const select = new Select();
|
||||
if (this.driver.dialect.limitSelect) select.topRecords = count;
|
||||
if (this.driver.dialect.rangeSelect)
|
||||
select.range = { offset: offset, limit: count };
|
||||
select.from = this.table;
|
||||
select.selectAll = true;
|
||||
const sql = select.toSql(this.driver);
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user