import { FindOptions } from 'sequelize/types'; import { ModelCtor } from 'sequelize-typescript'; import { CreatedByEntity } from '../models/created-by.entity'; import { JoinTableEntity } from '../models/join-table.entity'; import { AttributesOf } from '../types'; import { AuthenticatedUser } from './authenticated-user.interface'; import { UpdateOneToManyAssociationsOptions } from './update-one-to-many-associations-options.interface'; export interface UpdateManyToManyAssociationsOptions< T extends JoinTableEntity | CreatedByEntity, AuthenticatedUserType extends AuthenticatedUser = AuthenticatedUser, NewChildrenType = any > extends Omit< Omit, 'childTableModel'>, 'currentChildren' > { /** * The id of the parent instance */ parentInstanceId: number; /** * The sequelize model to use as a join table */ joinTableModel: ModelCtor; /** * The column name for foreign key on the join table for the parent */ parentForeignKey: keyof AttributesOf; /** * Attributes to request from the database. These are used when determining * if the child exists and to what parent it is related. Should be given * if default scope does not include enough information. */ joinTableFindAttributes: (keyof AttributesOf)[]; /** * If provided, these find options will be merged into the query to find all * children in the join table. The default find options these are merged into * request the joinTableFindAttributes and have a where clause that finds the * child rows based on the parentInstanceId/parentForeignKey. */ additionalJoinTableFindOptions?: FindOptions; }