Update collection.md

This commit is contained in:
Pearl C 2023-01-15 22:25:21 +08:00 committed by GitHub
parent f6bc966c20
commit 3e8d9e07a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@
## Overview ## Overview
`Collection` is used to define the data model in the system, such as model name, fields, indexes, associations and other information. It is usually called through the `collection` method of the `Database` instance as a proxy entry. `Collection` is used to define the data model in the system, such as model name, fields, indexes, associations, and other information. It is usually called through the `collection` method of the `Database` instance as a proxy entry.
```javascript ```javascript
const { Database } = require('@nocobase/database') const { Database } = require('@nocobase/database')
@ -42,7 +42,7 @@ Refer to [Fields](/api/database/field.md) for more field types.
| Name | Type | Default | Description | | Name | Type | Default | Description |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| `options.name` | `string` | - | collection identifier | | `options.name` | `string` | - | Identifier of the collection |
| `options.tableName?` | `string` | - | Database table name, the value of `options.name` is used if not set | | `options.tableName?` | `string` | - | Database table name, the value of `options.name` is used if not set |
| `options.fields?` | `FieldOptions[]` | - | Definition of fields, refer to [Field](./field) for details | | `options.fields?` | `FieldOptions[]` | - | Definition of fields, refer to [Field](./field) for details |
| `options.model?` | `string \| ModelStatic<Model>` | - | Model type of Sequelize; in case `string` is used, this model name needs to be registered in the db before being called | | `options.model?` | `string \| ModelStatic<Model>` | - | Model type of Sequelize; in case `string` is used, this model name needs to be registered in the db before being called |
@ -108,7 +108,7 @@ Match the Model type of Sequelize.
Data repository instance. Data repository instance.
## 字段配置方法 ## Field Configuration Method
### `getField()` ### `getField()`