mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 11:46:46 +00:00
docs: update api doc
This commit is contained in:
parent
34cec6480f
commit
a5e2d57894
@ -194,6 +194,8 @@ interface ImportOptions {
|
||||
// @default ['js', 'ts', 'json']
|
||||
extensions?: string[];
|
||||
}
|
||||
// 为了配合 db.import(),提供了一个 extend 方法,用于扩展已有 collection 配置
|
||||
function extend(collectionOptions: CollectionOptions, mergeOptions?: MergeOptions) {}
|
||||
```
|
||||
|
||||
##### Examples
|
||||
@ -244,6 +246,51 @@ extend({
|
||||
});
|
||||
```
|
||||
|
||||
extend 可以自定义 merge 规则([deepmerge](https://www.npmjs.com/package/deepmerge#options)),如:
|
||||
|
||||
```ts
|
||||
extend({
|
||||
name: 'demos',
|
||||
actions: [
|
||||
{
|
||||
name: 'list',
|
||||
},
|
||||
],
|
||||
}, {
|
||||
arrayMerge: (t, s) => t.concat(s),
|
||||
})
|
||||
```
|
||||
|
||||
备注:extend 的 fields、hooks 等 array 参数,默认都是 concat 规则,string 参数是覆盖,如:
|
||||
|
||||
```ts
|
||||
{
|
||||
name: 'tests',
|
||||
repository: 'TestRepository1',
|
||||
fields: [
|
||||
{ type: 'string', name: 'name1' },
|
||||
],
|
||||
}
|
||||
|
||||
extend({
|
||||
name: 'tests',
|
||||
repository: 'TestRepository2',
|
||||
fields: [
|
||||
{ type: 'string', name: 'name2' },
|
||||
],
|
||||
});
|
||||
|
||||
// 等同于
|
||||
{
|
||||
name: 'tests',
|
||||
repository: 'TestRepository2',
|
||||
fields: [
|
||||
{ type: 'string', name: 'name1' },
|
||||
{ type: 'string', name: 'name2' },
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
## `db.on()`
|
||||
|
||||
##### Definition
|
||||
|
Loading…
Reference in New Issue
Block a user