import TenantHandle from "./tenant-handle.js"; /** * Model query/create scope bound to one immutable tenant handle. * @template {typeof import("../database/record/index.js").default} MC */ export default class TenantModelScope { _handle: TenantHandle; _modelClass: MC; _databaseIdentifier: string; /** * Runs constructor. * @param {object} args - Scope arguments. * @param {import("../configuration.js").default} args.configuration - Owning configuration. * @param {MC} args.modelClass - Model class to bind. * @param {object} args.tenant - Ordinary or null-prototype JSON-compatible tenant descriptor. */ constructor({ configuration, modelClass, tenant }: { configuration: import("../configuration.js").default; modelClass: MC; tenant: object; }); /** * Runs a general model query/write callback on the captured physical tenant. * The query and every record/association it loads are owned by the operation * and must be used inside the callback. * @template T * @param {(query: import("../database/query/model-class-query.js").default, operation: import("../database/operation.js").default) => Promise} callback - Bound model callback. * @returns {Promise} - Callback result. */ databaseOperation(callback: (query: import("../database/query/model-class-query.js").default, operation: import("../database/operation.js").default) => Promise): Promise; /** * Runs a model callback in a transaction on the captured physical tenant. * @template T * @param {(query: import("../database/query/model-class-query.js").default, operation: import("../database/operation.js").default) => Promise} callback - Transaction callback. * @returns {Promise} - Callback result. */ transaction(callback: (query: import("../database/query/model-class-query.js").default, operation: import("../database/operation.js").default) => Promise): Promise; /** * Creates a record on the captured tenant. * @param {Record>} [attributes] - Create attributes. * @returns {Promise>} - Created record. */ create(attributes?: Record>): Promise>; /** * Counts records on the captured tenant. * @returns {Promise} - Count on the captured tenant. */ count(): Promise; /** * Finds a record by primary key on the captured tenant. * @param {string | number} recordId - Record identifier. * @returns {Promise | null>} - Found record. */ find(recordId: string | number): Promise | null>; /** * Finds a record by conditions on the captured tenant. * @param {Record} conditions - Finder conditions. * @returns {Promise | null>} - Found record. */ findBy(conditions: Record): Promise | null>; /** * Finds a record by conditions or raises on the captured tenant. * @param {Record} conditions - Finder conditions. * @returns {Promise>} - Found record. */ findByOrFail(conditions: Record): Promise>; /** * Loads all records on the captured tenant. * @returns {Promise[]>} - All records on the captured tenant. */ toArray(): Promise[]>; } //# sourceMappingURL=tenant-model-scope.d.ts.map