| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- import {RelationType} from './relation-type';
- /**
- * Relation definition.
- *
- * @example Available options.
- * ```ts
- * {
- * type: RelationType;
- * model?: string;
- * foreignKey?: string;
- * polymorphic?: boolean | string;
- * discriminator?: string;
- * }
- * ```
- */
- export declare type RelationDefinition =
- // belongsTo
- | BelongsToDefinition
- | PolyBelongsToDefinition
- // hasOne
- | HasOneDefinition
- | PolyHasOneDefinitionWithTargetRelationName
- | PolyHasOneDefinitionWithTargetKeys
- // hasMany
- | HasManyDefinition
- | PolyHasManyDefinitionWithTargetRelationName
- | PolyHasManyDefinitionWithTargetKeys
- // referencesMany
- | ReferencesManyDefinition;
- /**
- * The regular "belongsTo" relation.
- *
- * @example Required options only.
- * ```
- * {
- * type: RelationType.BELONGS_TO,
- * model: 'model',
- * }
- * ```
- *
- * @example Verbose definition.
- * ```
- * {
- * type: RelationType.BELONGS_TO,
- * model: 'model',
- * foreignKey: 'modelId',
- * }
- * ```
- */
- export declare type BelongsToDefinition = {
- type: RelationType.BELONGS_TO;
- polymorphic?: false;
- model: string;
- foreignKey?: string;
- };
- /**
- * The polymorphic "belongsTo" relation.
- *
- * @example Required fields only.
- * ```
- * {
- * type: RelationType.BELONGS_TO,
- * polymorphic: true,
- * }
- * ```
- *
- * @example Verbose definition.
- * ```
- * {
- * type: RelationType.BELONGS_TO,
- * polymorphic: true,
- * foreignKey: 'referenceId',
- * discriminator: 'referenceType,
- * }
- * ```
- */
- export declare type PolyBelongsToDefinition = {
- type: RelationType.BELONGS_TO;
- polymorphic: true;
- foreignKey?: string;
- discriminator?: string;
- };
- /**
- * The regular "hasOne" relation.
- *
- * @example
- * ```ts
- * {
- * type: RelationType.HAS_ONE,
- * model: 'model',
- * foreignKey: 'modelId',
- * }
- * ```
- */
- export declare type HasOneDefinition = {
- type: RelationType.HAS_ONE;
- model: string;
- polymorphic?: false;
- foreignKey?: string;
- discriminator?: undefined;
- };
- /**
- * The polymorphic "hasOne" relation with a target relation name.
- *
- * @example
- * ```ts
- * {
- * type: RelationType.HAS_ONE,
- * model: 'model',
- * polymorphic: 'reference',
- * }
- * ```
- */
- export declare type PolyHasOneDefinitionWithTargetRelationName = {
- type: RelationType.HAS_ONE;
- model: string;
- polymorphic: string;
- foreignKey?: undefined;
- discriminator?: undefined;
- };
- /**
- * The polymorphic "hasOne" relation with target relation keys.
- *
- * @example Required options only.
- * ```
- * {
- * type: RelationType.HAS_ONE,
- * model: 'model',
- * polymorphic: true,
- * }
- * ```
- *
- * @example Verbose definition.
- * ```
- * {
- * type: RelationType.HAS_ONE,
- * model: 'model',
- * polymorphic: true,
- * foreignKey: 'referenceId',
- * discriminator: 'referenceType,
- * }
- * ```
- */
- export declare type PolyHasOneDefinitionWithTargetKeys = {
- type: RelationType.HAS_ONE;
- model: string;
- polymorphic: true;
- foreignKey?: string;
- discriminator?: string;
- };
- /**
- * The regular "hasMany" relation.
- *
- * @example
- * ```ts
- * {
- * type: RelationType.HAS_MANY,
- * model: 'model',
- * foreignKey: 'modelId',
- * }
- * ```
- */
- export declare type HasManyDefinition = {
- type: RelationType.HAS_MANY;
- model: string;
- polymorphic?: false;
- foreignKey?: string;
- discriminator?: undefined;
- };
- /**
- * The polymorphic "hasMany" relation with a target relation name.
- *
- * @example
- * ```ts
- * {
- * type: RelationType.HAS_MANY,
- * model: 'model',
- * polymorphic: 'reference',
- * }
- * ```
- */
- export declare type PolyHasManyDefinitionWithTargetRelationName = {
- type: RelationType.HAS_MANY;
- model: string;
- polymorphic: string;
- foreignKey?: undefined;
- discriminator?: undefined;
- };
- /**
- * The polymorphic "hasMany" relation with target relation keys.
- *
- * @example Required options only.
- * ```
- * {
- * type: RelationType.HAS_MANY,
- * model: 'model',
- * polymorphic: true,
- * }
- * ```
- *
- * @example Verbose definition.
- * ```
- * {
- * type: RelationType.HAS_MANY,
- * model: 'model',
- * polymorphic: true,
- * foreignKey: 'referenceId',
- * discriminator: 'referenceType,
- * }
- * ```
- */
- export declare type PolyHasManyDefinitionWithTargetKeys = {
- type: RelationType.HAS_MANY;
- model: string;
- polymorphic: true;
- foreignKey?: string;
- discriminator?: string;
- };
- /**
- * The regular "referencesMany" relation.
- *
- * @example Required options only.
- * ```
- * {
- * type: RelationType.REFERENCES_MANY,
- * model: 'model',
- * }
- * ```
- *
- * @example Verbose definition.
- * ```
- * {
- * type: RelationType.REFERENCES_MANY,
- * model: 'model',
- * foreignKey: 'modelIds',
- * }
- * ```
- */
- export declare type ReferencesManyDefinition = {
- type: RelationType.REFERENCES_MANY;
- model: string;
- foreignKey?: string;
- discriminator?: undefined;
- };
|