mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
add an endpoint for doing SQL selects (#641)
* add an endpoint for doing SQL selects This adds an endpoint for doing SQL selects directly on a Grist document. Other kinds of statements are not supported. There is a default timeout of a second on queries. This follows loosely an API design by Alex Hall. Co-authored-by: jarek <jaroslaw.sadzinski@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as sqlite3 from '@gristlabs/sqlite3';
|
||||
import { fromCallback } from 'app/server/lib/serverUtils';
|
||||
import { MinDB, PreparedStatement, ResultRow, SqliteVariant } from 'app/server/lib/SqliteCommon';
|
||||
import { MinDB, MinDBOptions, PreparedStatement, ResultRow, SqliteVariant } from 'app/server/lib/SqliteCommon';
|
||||
import { OpenMode, RunResult } from 'app/server/lib/SQLiteDB';
|
||||
|
||||
export class NodeSqliteVariant implements SqliteVariant {
|
||||
@@ -84,6 +84,17 @@ export class NodeSqlite3DatabaseAdapter implements MinDB {
|
||||
this._db.close();
|
||||
}
|
||||
|
||||
public async interrupt(): Promise<void> {
|
||||
this._db.interrupt();
|
||||
}
|
||||
|
||||
public getOptions(): MinDBOptions {
|
||||
return {
|
||||
canInterrupt: true,
|
||||
bindableMethodsProcessOneStatement: true,
|
||||
};
|
||||
}
|
||||
|
||||
public async allMarshal(sql: string, ...params: any[]): Promise<Buffer> {
|
||||
// allMarshal isn't in the typings, because it is our addition to our fork of sqlite3 JS lib.
|
||||
return fromCallback(cb => (this._db as any).allMarshal(sql, ...params, cb));
|
||||
|
||||
Reference in New Issue
Block a user