mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
3d3a5e334a
Summary: Updates to Plugin API documentation. Test Plan: Tested manually in grist-help. Reviewers: jarek Reviewed By: jarek Subscribers: jarek Differential Revision: https://phab.getgrist.com/D3447
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import * as Types from 'app/plugin/DocApiTypes';
|
|
|
|
/**
|
|
* Offer CRUD-style operations on a table.
|
|
*/
|
|
export interface TableOperations {
|
|
/**
|
|
* Create a record or records.
|
|
*/
|
|
create(records: Types.NewRecord, options?: OpOptions): Promise<Types.MinimalRecord>;
|
|
create(records: Types.NewRecord[], options?: OpOptions): Promise<Types.MinimalRecord[]>;
|
|
|
|
/**
|
|
* Update a record or records.
|
|
*/
|
|
update(records: Types.Record|Types.Record[], options?: OpOptions): Promise<void>;
|
|
|
|
/**
|
|
* Delete a record or records.
|
|
*/
|
|
destroy(recordIds: Types.RecordId|Types.RecordId[]): Promise<void>;
|
|
|
|
/**
|
|
* Add or update a record or records.
|
|
*/
|
|
upsert(records: Types.AddOrUpdateRecord|Types.AddOrUpdateRecord[],
|
|
options?: UpsertOptions): Promise<void>;
|
|
|
|
/**
|
|
* Determine the tableId of the table.
|
|
*/
|
|
getTableId(): Promise<string>;
|
|
|
|
// TODO: offer a way to query the table.
|
|
// select(): Records;
|
|
}
|
|
|
|
/**
|
|
* General options for table operations.
|
|
*/
|
|
export interface OpOptions {
|
|
/** Whether to parse strings based on the column type. Defaults to true. */
|
|
parseStrings?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Extra options for upserts.
|
|
*/
|
|
export interface UpsertOptions extends OpOptions {
|
|
/** Permit inserting a record. Defaults to true. */
|
|
add?: boolean;
|
|
/** Permit updating a record. Defaults to true. */
|
|
update?: boolean;
|
|
/** Whether to update none, one, or all matching records. Defaults to "first". */
|
|
onMany?: 'none' | 'first' | 'all';
|
|
/** Allow "wildcard" operation. Defaults to false. */
|
|
allowEmptyRequire?: boolean;
|
|
}
|