export type InstanceRelationshipsBaseArgs = { /** * - Parent model instance. */ model: InstanceType; /** * - Relationship metadata definition. */ relationship: import("../relationships/base.js").default; }; /** * InstanceRelationshipsBaseArgs type. * @template {typeof import("../index.js").default} [MC=typeof import("../index.js").default] * @template {typeof import("../index.js").default} [TMC=typeof import("../index.js").default] * @typedef {object} InstanceRelationshipsBaseArgs * @property {InstanceType} model - Parent model instance. * @property {import("../relationships/base.js").default} relationship - Relationship metadata definition. */ /** * A generic query over some model type. * @template {typeof import("../index.js").default} [MC=typeof import("../index.js").default] * @template {typeof import("../index.js").default} [TMC=typeof import("../index.js").default] */ export default class VelociousDatabaseRecordBaseInstanceRelationship { _dirty: boolean; model: InstanceType; relationship: import("../relationships/base.js").default; /** * Auto save. * @type {boolean | undefined} */ _autoSave: boolean | undefined; /** * Preloaded. * @type {boolean | undefined} */ _preloaded: boolean | undefined; /** * Loaded. * @type {InstanceType | Array> | undefined} */ _loaded: InstanceType | Array> | undefined; /** * Runs constructor. * @param {InstanceRelationshipsBaseArgs} args - Options object. */ constructor({ model, relationship }: InstanceRelationshipsBaseArgs); /** * Runs add to loaded. * @abstract * @param {InstanceType[] | InstanceType} models - Model instances. * @returns {void} - No return value. */ addToLoaded(models: InstanceType[] | InstanceType): void; /** * Runs build. * @abstract * @param {ConstructorParameters[0]} attributes - Target model write attributes. * @returns {InstanceType} - The build. */ build(attributes: ConstructorParameters[0]): InstanceType; /** * Resolves a relationship target through the source record's operation and * metadata generation before construction. * @returns {TMC | undefined} - Bound target model class. */ getBoundTargetModelClass(): TMC | undefined; /** * Runs get auto save. * @returns {boolean | undefined} Whether the relationship should be auto-saved before saving the parent model */ getAutoSave(): boolean | undefined; /** * Runs set auto save. * @param {boolean} newAutoSaveValue Whether the relationship should be auto-saved before saving the parent model * @returns {void} - No return value. */ setAutoSave(newAutoSaveValue: boolean): void; /** * Runs set dirty. * @param {boolean} newValue Whether the relationship is dirty (has been modified) * @returns {void} - No return value. */ setDirty(newValue: boolean): void; /** * Runs get dirty. * @returns {boolean} Whether the relationship is dirty (has been modified) */ getDirty(): boolean; /** * Runs load. * @abstract * @returns {Promise | Array> | undefined>} - Resolves with loaded relationship value. */ load(): Promise | Array> | undefined>; /** * Loads the relationship if not already loaded. When the parent record was * loaded as part of a batch (cohort) and autoload is enabled, siblings in * the cohort that share this relationship and have not preloaded it yet * are batched into a single query via the existing preloader path. * @returns {Promise | Array> | undefined>} - Resolves with loaded relationship value. */ autoloadOrLoad(): Promise | Array> | undefined>; /** * Attempts to batch-load this relationship across cohort siblings via the * existing preloader path. Returns true when a batch ran (self is always * included because callers reset their own `_preloaded` state before * calling), false when autoload is off, there is no cohort, or no batch * candidates remain. Siblings that have already preloaded this relationship * are skipped so their cached value is preserved. * @returns {Promise} - Whether a cohort batch preload ran. */ _tryCohortPreload(): Promise; /** * Runs is loaded. * @returns {boolean} Whether the relationship has been preloaded */ isLoaded(): boolean; /** * Runs loaded. * @returns {InstanceType | Array> | undefined} The loaded model or models (depending on relationship type) */ loaded(): InstanceType | Array> | undefined; /** * Runs set loaded. * @param {InstanceType | Array> | undefined} model - Related model(s) to mark as loaded. */ setLoaded(model: InstanceType | Array> | undefined): void; /** * Runs get loaded or undefined. * @returns {InstanceType | InstanceType[] | undefined} - The loaded or undefined. */ getLoadedOrUndefined(): InstanceType | InstanceType[] | undefined; /** * Runs get preloaded. * @returns {boolean} The loaded model or models (depending on relationship type) */ getPreloaded(): boolean; /** * Runs set preloaded. * @param {boolean} isPreloaded - Whether the relationship is preloaded. */ setPreloaded(isPreloaded: boolean): void; /** * Runs get foreign key. * @returns {string} The foreign key for this relationship */ getForeignKey(): string; /** * Runs get model. * @returns {InstanceType} - The model. */ getModel(): InstanceType; /** * Runs get primary key. * @returns {string} The primary key for this relationship's model */ getPrimaryKey(): string; /** * Runs get relationship. * @returns {import("../relationships/base.js").default} The relationship object that this instance relationship is based on */ getRelationship(): import("../relationships/base.js").default; /** * Runs apply scope. * @template T * @param {T} query - Query instance. * @returns {T} - Scoped query. */ applyScope(query: T): T; /** * Runs get target model class. * @returns {TMC | undefined} The model class that this instance relationship */ getTargetModelClass(): TMC | undefined; /** * Runs get type. * @returns {string} The type of relationship (e.g. "has_many", "belongs_to", etc.) */ getType(): string; } //# sourceMappingURL=base.d.ts.map