Update has-many-repository.md
This commit is contained in:
parent
dba8bbd5c5
commit
f35bdc522d
@ -1,42 +1,41 @@
|
|||||||
|
|
||||||
# HasManyRepository
|
# HasManyRepository
|
||||||
|
|
||||||
`HasManyRepository` 是用于处理 `HasMany` 关系的 `Relation Repository`。
|
`HasManyRepository` is the `Relation Repository` for handling `HasMany` relationships.
|
||||||
|
|
||||||
## 类方法
|
## Class Method
|
||||||
|
|
||||||
### `find()`
|
### `find()`
|
||||||
|
|
||||||
查找关联对象
|
Find associated objects.
|
||||||
|
|
||||||
**签名**
|
**Signature**
|
||||||
|
|
||||||
* `async find(options?: FindOptions): Promise<M[]>`
|
* `async find(options?: FindOptions): Promise<M[]>`
|
||||||
|
|
||||||
**详细信息**
|
**Detailed Information**
|
||||||
|
|
||||||
查询参数与 [`Repository.find()`](../repository.md#find) 一致。
|
Query parameters are the same as [`Repository.find()`](../repository.md#find).
|
||||||
|
|
||||||
### `findOne()`
|
### `findOne()`
|
||||||
|
|
||||||
查找关联对象,仅返回一条记录
|
Find associated objects, only to return one record.
|
||||||
|
|
||||||
**签名**
|
**Signature**
|
||||||
|
|
||||||
* `async findOne(options?: FindOneOptions): Promise<M>`
|
* `async findOne(options?: FindOneOptions): Promise<M>`
|
||||||
|
|
||||||
<embed src="../shared/find-one.md"></embed>
|
<embed src="../shared/find-one.md"></embed>
|
||||||
|
|
||||||
|
|
||||||
### `count()`
|
### `count()`
|
||||||
|
|
||||||
返回符合查询条件的记录数
|
Return the number of records matching the query criteria.
|
||||||
|
|
||||||
**签名**
|
**Signature**
|
||||||
|
|
||||||
* `async count(options?: CountOptions)`
|
* `async count(options?: CountOptions)`
|
||||||
|
|
||||||
**类型**
|
**Type**
|
||||||
```typescript
|
```typescript
|
||||||
interface CountOptions extends Omit<SequelizeCountOptions, 'distinct' | 'where' | 'include'>, Transactionable {
|
interface CountOptions extends Omit<SequelizeCountOptions, 'distinct' | 'where' | 'include'>, Transactionable {
|
||||||
filter?: Filter;
|
filter?: Filter;
|
||||||
@ -45,23 +44,22 @@ interface CountOptions extends Omit<SequelizeCountOptions, 'distinct' | 'where'
|
|||||||
|
|
||||||
### `findAndCount()`
|
### `findAndCount()`
|
||||||
|
|
||||||
从数据库查询特定条件的数据集和结果数。
|
Find datasets from the database with the specified filtering conditions and return the number of results.
|
||||||
|
|
||||||
**签名**
|
**Signature**
|
||||||
|
|
||||||
* `async findAndCount(options?: FindAndCountOptions): Promise<[any[], number]>`
|
* `async findAndCount(options?: FindAndCountOptions): Promise<[any[], number]>`
|
||||||
|
|
||||||
**类型**
|
**Type**
|
||||||
```typescript
|
```typescript
|
||||||
type FindAndCountOptions = CommonFindOptions
|
type FindAndCountOptions = CommonFindOptions
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### `create()`
|
### `create()`
|
||||||
|
|
||||||
创建关联对象
|
Create associated objects.
|
||||||
|
|
||||||
**签名**
|
**Signature**
|
||||||
|
|
||||||
* `async create(options?: CreateOptions): Promise<M>`
|
* `async create(options?: CreateOptions): Promise<M>`
|
||||||
|
|
||||||
@ -69,9 +67,9 @@ type FindAndCountOptions = CommonFindOptions
|
|||||||
|
|
||||||
### `update()`
|
### `update()`
|
||||||
|
|
||||||
更新符合条件的关联对象
|
Update associated objects that match the conditions.
|
||||||
|
|
||||||
**签名**
|
**Signature**
|
||||||
|
|
||||||
* `async update(options?: UpdateOptions): Promise<M>`
|
* `async update(options?: UpdateOptions): Promise<M>`
|
||||||
|
|
||||||
@ -79,9 +77,9 @@ type FindAndCountOptions = CommonFindOptions
|
|||||||
|
|
||||||
### `destroy()`
|
### `destroy()`
|
||||||
|
|
||||||
删除符合条件的关联对象
|
Delete associated objects.
|
||||||
|
|
||||||
**签名**
|
**Signature**
|
||||||
|
|
||||||
* `async destroy(options?: TK | DestroyOptions): Promise<M>`
|
* `async destroy(options?: TK | DestroyOptions): Promise<M>`
|
||||||
|
|
||||||
@ -89,44 +87,43 @@ type FindAndCountOptions = CommonFindOptions
|
|||||||
|
|
||||||
### `add()`
|
### `add()`
|
||||||
|
|
||||||
添加对象关联关系
|
Add association relationships between objects.
|
||||||
|
|
||||||
**签名**
|
**Signature**
|
||||||
* `async add(options: TargetKey | TargetKey[] | AssociatedOptions)`
|
* `async add(options: TargetKey | TargetKey[] | AssociatedOptions)`
|
||||||
|
|
||||||
**类型**
|
**Type**
|
||||||
```typescript
|
```typescript
|
||||||
interface AssociatedOptions extends Transactionable {
|
interface AssociatedOptions extends Transactionable {
|
||||||
tk?: TargetKey | TargetKey[];
|
tk?: TargetKey | TargetKey[];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**详细信息**
|
**Detailed Information**
|
||||||
|
|
||||||
* `tk` - 关联对象的 targetKey 值,可以是单个值,也可以是数组。
|
* `tk` - The targetKey value of the associated object, either as a single value or an array.
|
||||||
<embed src="../shared/transaction.md"></embed>
|
<embed src="../shared/transaction.md"></embed>
|
||||||
|
|
||||||
### `remove()`
|
### `remove()`
|
||||||
|
|
||||||
移除与给定对象之间的关联关系
|
Remove the association with the given object.
|
||||||
|
|
||||||
|
**Signature**
|
||||||
|
|
||||||
**签名**
|
|
||||||
* `async remove(options: TargetKey | TargetKey[] | AssociatedOptions)`
|
* `async remove(options: TargetKey | TargetKey[] | AssociatedOptions)`
|
||||||
|
|
||||||
**详细信息**
|
**Detailed Information**
|
||||||
|
|
||||||
参数同 [`add()`](#add) 方法。
|
Same parameters as the [`add()`](#add) method.
|
||||||
|
|
||||||
### `set()`
|
### `set()`
|
||||||
|
|
||||||
设置当前关系的关联对象
|
Set the associated object of the current relationship.
|
||||||
|
|
||||||
**签名**
|
**Signature**
|
||||||
|
|
||||||
* `async set(options: TargetKey | TargetKey[] | AssociatedOptions)`
|
* `async set(options: TargetKey | TargetKey[] | AssociatedOptions)`
|
||||||
|
|
||||||
**详细信息**
|
**Detailed Information**
|
||||||
|
|
||||||
参数同 [`add()`](#add) 方法。
|
|
||||||
|
|
||||||
|
|
||||||
|
Same parameters as the [`add()`](#add) method.
|
||||||
|
Loading…
Reference in New Issue
Block a user