/** * Interface definition for pure CRUD operations. * @see https://en.wikipedia.org/wiki/Create,_read,_update_and_delete */ export interface CRUDEngineBase { /** * Creates a record by its primary key within a table. * @param tableName Table name * @param primaryKey Primary key to be used to store the record * @param entity Any kind of object that should be stored * @returns Resolves with the primary key of the stored record. */ create(tableName: string, primaryKey: PrimaryKey, entity: EntityType): Promise; /** * Finds a record by its primary key within a table. * @param tableName Table name * @param primaryKey Primary key to query the record * @throws {RecordNotFoundError} Will be thrown, if the record could not be found. * @returns Resolves with the record. */ read(tableName: string, primaryKey: PrimaryKey): Promise; /** * Updates a record with a set of properties. * @param tableName Table name * @param primaryKey Primary key of record which should get updated * @param changes Updated properties that should be saved for the record * @returns Resolves with the primary key of the updated record. */ update(tableName: string, primaryKey: PrimaryKey, changes: ChangesType): Promise; /** * Deletes a record by its primary key within a table. * @param tableName Table name * @param primaryKey Primary key to be used to delete the record * @returns Resolves with the primary key of the deleted record. */ delete(tableName: string, primaryKey: PrimaryKey): Promise; } /** * Interface definition for CRUD operations with support for collections. */ export interface CRUDEngineBaseCollection extends CRUDEngineBase { /** * Reads all records from a table. */ readAll(tableName: string): Promise; /** * Returns all primary keys of records that are stored in a table. */ readAllPrimaryKeys(tableName: string): Promise; /** * Deletes all records within a table. * @param tableName Table name * @returns Resolves with `true`, if all records have been removed. */ deleteAll(tableName: string): Promise; } /** * Extends collection-aware CRUD operations with convenience methods for practical usage in web applications (such as "Wire for Web"). */ export interface CRUDEngine extends CRUDEngineBaseCollection { [index: string]: any; /** * Clears all tables without deleting them. * @returns Resolves when all tables are cleared. */ clearTables(): Promise; /** * Initializes the store engine. This needs to be done prior to operating with it. * @param storeName Name of the store * @param settings Database-specific settings * @returns Resolves with the underlying (unwrapped) instance of a database. * @throws {UnsupportedError} Error when feature is not available on targeted platform. */ init(storeName: string, ...settings: any[]): Promise; /** * Checks wether the engine is supported in the current environment. * @returns Resolves if supported, rejects if unsupported. */ isSupported(): Promise; /** * Deletes the store. * @returns Resolves if store got deleted. */ purge(): Promise; storeName: string; /** * Updates a record with a set of properties. * If the record doesn't exist, The record will be created automatically. * @param tableName Table name * @param primaryKey Primary key of record which should get updated * @param changes Updated properties that should be saved for the record * @returns Resolves with the primary key of the updated record. */ updateOrCreate(tableName: string, primaryKey: PrimaryKey, changes: ChangesType): Promise; } //# sourceMappingURL=CRUDEngine.d.ts.map