Update index.md

This commit is contained in:
Pearl C 2023-01-14 16:08:22 +08:00 committed by GitHub
parent 66ce671233
commit f6445b8ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -209,7 +209,7 @@ Get the table name prefix in the configuration.
### `collection()` ### `collection()`
Define a data table. This is similar to the `define` method of Sequelize, which only creates table structure in memory. Call the `sync` method if it is needed to be persisted to the database. Define a data table. This is like the `define` method of Sequelize, which only creates table structure in memory. Call the `sync` method if it is needed to be persisted to the database.
**Signature** **Signature**
@ -371,7 +371,7 @@ Register custom field type.
**Parameter** **Parameter**
`fieldTypes` is a key-value pair, where key is the field type name and value is the field type class. `fieldTypes` is a key-value pair, where key is the field type name, and value is the field type class.
**Example** **Example**
@ -397,7 +397,7 @@ Register custom data model class.
**Parameter** **Parameter**
`models` is a key-value pair, where key is the data model name and value is the data model class. `models` is a key-value pair, where key is the data model name, and value is the data model class.
**Example** **Example**
@ -428,7 +428,7 @@ Register custom data repository class.
**Parameter** **Parameter**
`repositories` is a key-value pair, where key is the data repository name and value is the data repository class. `repositories` is a key-value pair, where key is the data repository name, and value is the data repository class.
**Example** **Example**
@ -508,7 +508,7 @@ const ModelClass = db.getModel('books');
console.log(ModelClass.prototype instanceof MyModel) // true console.log(ModelClass.prototype instanceof MyModel) // true
``` ```
Note: The model class retrieved from collection is not strictly equivalent to the model class at registration, but is inherited from the model class at registration. Since the properties of Sequelize's model class are modified during initialization, NocoBase automatically handles this inheritance relationship. All thr definitions work fine except that the classes are not equal. Note: The model class retrieved from collection is not strictly equivalent to the model class at registration, but is inherited from the model class at registration. Since the properties of Sequelize's model class are modified during initialization, NocoBase automatically handles this inheritance relationship. All the definitions work fine except that the classes are not equal.
### `getRepository()` ### `getRepository()`
@ -747,7 +747,7 @@ export default extend({
If the above two files are imported when calling `import()`, after being extended again by `extend()`, the table <i>books</i> will have `title` and `price` two fields. If the above two files are imported when calling `import()`, after being extended again by `extend()`, the table <i>books</i> will have `title` and `price` two fields.
This method is espeically useful when extending the table structure that is already defined by existing plugin. This method is especially useful when extending the table structure that is already defined by existing plugin.
## Built-in Events ## Built-in Events
@ -794,7 +794,7 @@ await users.sync();
### `'beforeValidate'` / `'afterValidate'` ### `'beforeValidate'` / `'afterValidate'`
Before creating or updating data, there is a validation againist the data based on the rules defined by the collection, and the corresponding events are triggered before and after the validation. This is triggered when `repository.create()` or `repository.update()` is called. Before creating or updating data, there is a validation against the data based on the rules defined by the collection, and the corresponding events are triggered before and after the validation. This is triggered when `repository.create()` or `repository.update()` is called.
**Signature** **Signature**