RelationRepository 是关系类型的 Repository 对象,RelationRepository 可以实现在不加载关联的情况下对关联数据进行操作。基于 RelationRepository,每种关联都派生出对应的实现,分别为
HasOneRepositoryHasManyRepositoryBelongsToRepositoryBelongsToManyRepository签名
constructor(sourceCollection: Collection, association: string, sourceKeyValue: string | number)参数
| 参数名 | 类型 | 默认值 | 描述 |
|---|---|---|---|
sourceCollection | Collection | - | 关联中的参照关系(referencing relation)对应的 Collection |
association | string | - | 关联名称 |
sourceKeyValue | string | number | - | 参照关系中对应的 key 值 |
db: Database数据库对象
sourceCollection关联中的参照关系(referencing relation)对应的 Collection
targetCollection关联中被参照关系(referenced relation)对应的 Collection
associationsequelize 中的与当前关联对应的 association 对象
associationFieldcollection 中的与当前关联对应的字段
sourceKeyValue参照关系中对应的 key 值