logologo
开始
教程
手册
开发
插件
API
首页
English
简体中文
日本語
한국어
Español
Português
Deutsch
Français
Русский
开始
教程
手册
开发
插件
API
首页
logologo
API Overview

@nocobase/auth

AuthManager
Auth
BaseAuth

@nocobase/cache

CacheManager
Cache

@nocobase/cli

NocoBase CLI
全局环境变量

@nocobase/client

Application (Client)
Plugin (Client)

@nocobase/database

Collection
Field

interfaces

BaseInterface
Filter Operators

RelationRepository

BelongsToManyRepository
BelongsToRepository
HasManyRepository
HasOneRepository
Repository

Repository 共享参数

CreateOptions
DestroyOptions
FindOneOptions
FindOptions
Transaction 事务参数
UpdateOptions

@nocobase/data-source-manager

DataSourceManager
DataSource (abstract)
ICollectionManager
ICollection
IField
IModel
IRepository

@nocobase/flow-engine

DataSourceManager (FlowEngine)
FlowContext
FlowEngine
FlowModel
FlowResource

@nocobase/logger

Logger

@nocobase/server

AppCommand
Application (Server)
AuditManager
Context (Server)
Migration
Plugin (Server)

@nocobase/sdk

Auth (SDK)
Storage (SDK)

@nocobase/telemetry

Metric
Telemetry
Trace
Previous PageFilter Operators
Next PageBelongsToManyRepository

#RelationRepository

RelationRepository 是关系类型的 Repository 对象,RelationRepository 可以实现在不加载关联的情况下对关联数据进行操作。基于 RelationRepository,每种关联都派生出对应的实现,分别为

  • HasOneRepository
  • HasManyRepository
  • BelongsToRepository
  • BelongsToManyRepository

#构造函数

签名

  • constructor(sourceCollection: Collection, association: string, sourceKeyValue: string | number)

参数

参数名类型默认值描述
sourceCollectionCollection-关联中的参照关系(referencing relation)对应的 Collection
associationstring-关联名称
sourceKeyValuestring | number-参照关系中对应的 key 值

#基类属性

#db: Database

数据库对象

#sourceCollection

关联中的参照关系(referencing relation)对应的 Collection

#targetCollection

关联中被参照关系(referenced relation)对应的 Collection

#association

sequelize 中的与当前关联对应的 association 对象

#associationField

collection 中的与当前关联对应的字段

#sourceKeyValue

参照关系中对应的 key 值