import type { Entity } from './Entity'; import type { IReadonlyRepository } from './IReadonlyRepository'; import type { CreateUpdateOptions, // DeleteOptions, DestroyResult, DoNotReturnRecords, ReturnSelect, WhereQuery } from './query'; import type { CreateOptions } from './query/CreateOptions'; import type { OnConflictOptions } from './query/OnConflictOptions'; import type { CreateUpdateParams, QueryResult } from './types'; export interface IRepository extends IReadonlyRepository { /** * Creates an object using the specified values * @param {object} values - Values to insert as multiple new objects. * @param {object} [options] * @param {string[]} [options.returnSelect] - Array of model property names to return from the query. * @param {object} [options.onConflict] - Options to handle conflicts due to a unique constraint or exclusion constraint error during insert * @returns {object} */ create(values: CreateUpdateParams, options?: OnConflictOptions | (Partial> & ReturnSelect)): Promise>; /** * Creates an object or objects using the specified values * @param {object|object[]} values - Values to insert as multiple new objects. * @param {object} options * @param {boolean} options.returnRecords - Determines if inserted records should be returned * @param {object} [options.onConflict] - Options to handle conflicts due to a unique constraint or exclusion constraint error during insert * @returns {void} */ create(values: CreateUpdateParams | CreateUpdateParams[], options: DoNotReturnRecords & Partial>): Promise; /** * Creates objects using the specified values * @param {object[]} values - Values to insert as multiple new objects. * @param {object} [options] * @param {object} [options.onConflict] - Options to handle conflicts due to a unique constraint or exclusion constraint error during insert * @param {string[]} [options.returnSelect] - Array of model property names to return from the query. * @returns {object[]} */ create(values: CreateUpdateParams[], options?: (OnConflictOptions & Partial>) | (Partial> & ReturnSelect)): Promise[]>; /** * Creates an object using the specified values * @param {object|object[]} values - Values to insert as a new object. If an array is specified, multiple rows will be inserted * @param {object} [options] * @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned * @param {string[]} [options.returnSelect] - Array of model property names to return from the query. * @param {object} [options.onConflict] - Options to handle conflicts due to a unique constraint or exclusion constraint error during insert * @returns {object|object[]|void} Return value from the db */ create(values: CreateUpdateParams | CreateUpdateParams[], options?: CreateOptions): Promise | QueryResult[] | void>; /** * Updates object(s) matching the where query, with the specified values * @param {object} where - Object representing the where query * @param {object} values - Values to update * @param {object} options * @param {boolean} options.returnRecords - Determines if inserted records should be returned * @param {{returnRecords: false}} options * @returns {void} */ update(where: WhereQuery, values: CreateUpdateParams, options: DoNotReturnRecords): Promise; /** * Updates object(s) matching the where query, with the specified values * @param {object} where - Object representing the where query * @param {object} values - Values to update * @param {object} [options] - Values to update * @param {string[]} [options.returnSelect] - Array of model property names to return from the query. * @returns {object[]} */ update(where: WhereQuery, values: CreateUpdateParams, options?: ReturnSelect): Promise[]>; /** * Updates object(s) matching the where query, with the specified values * @param {object} where - Object representing the where query * @param {object} values - Values to update * @param {object} [options] * @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned * @param {string[]} [options.returnSelect] - Array of model property names to return from the query. * @returns {object[]|void} Return values from the db or `true` if returnRecords=false */ update(where: WhereQuery, values: CreateUpdateParams, options?: CreateUpdateOptions): Promise[] | void>; /** * Destroys object(s) matching the where query * @param {object} [where] - Object representing the where query * @returns {void} */ destroy(where?: WhereQuery): DestroyResult; /** * Destroys object(s) matching the where query * @param {object} where - Object representing the where query * @param {object} options - Determines if inserted records should be returned * @param {boolean} [options.returnRecords] - Determines if inserted records should be returned * @param {string[]} [options.returnSelect] - Array of model property names to return from the query. * @returns {object[]} */ destroy(where: WhereQuery, options: DeleteOptions): DestroyResult[]>; /** * Destroys object(s) matching the where query * @param {object} where - Object representing the where query * @param {object} [options] * @param {boolean} [options.returnRecords=false] - Determines if inserted records should be returned * @param {string[]} [options.returnSelect] - Array of model property names to return from the query. * @returns {object[]|void} `void` or records affected if returnRecords=true */ destroy = DeleteOptions>(where: WhereQuery, options?: TOptions): DestroyResult ? void : QueryResult[]>; }