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:
@@ -96,6 +96,17 @@ export class AppSettings {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* As for readInt() but fail if nothing was found.
|
||||
*/
|
||||
public requireInt(query: AppSettingQuery): number {
|
||||
const result = this.readInt(query);
|
||||
if (result === undefined) {
|
||||
throw new Error(`missing environment variable: ${query.envVar}`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* As for read() but type (and store, and report) the result as
|
||||
* a boolean.
|
||||
@@ -107,6 +118,17 @@ export class AppSettings {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* As for read() but type (and store, and report) the result as
|
||||
* an integer (well, a number).
|
||||
*/
|
||||
public readInt(query: AppSettingQuery): number|undefined {
|
||||
this.readString(query);
|
||||
const result = this.getAsInt();
|
||||
this._value = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* set this setting 'manually' */
|
||||
public set(value: JSONValue): void {
|
||||
this._value = value;
|
||||
|
||||
Reference in New Issue
Block a user