feat: update api doc

This commit is contained in:
chenos 2021-11-16 11:06:17 +08:00
parent 9a5ea406f9
commit 2755068edb
5 changed files with 502 additions and 46 deletions

View File

@ -30,7 +30,7 @@ const Navbar: FC<INavbarProps> = ({ onMobileMenuClick, navPrefix, location }) =>
to={base} to={base}
data-plaintext={logo === false || undefined} data-plaintext={logo === false || undefined}
> >
{title} {/* {title} */}
</Link> </Link>
<nav> <nav>
{navPrefix} {navPrefix}

View File

@ -6,7 +6,7 @@ console.log('baseUrl', baseUrl);
process.env.MFSU_AD = 'none'; process.env.MFSU_AD = 'none';
export default defineConfig({ export default defineConfig({
title: ' ', title: 'NocoBase',
hash: true, hash: true,
define: { define: {
'process.env.API_URL': process.env.API_URL || `${baseUrl}api/`, 'process.env.API_URL': process.env.API_URL || `${baseUrl}api/`,

View File

@ -97,33 +97,6 @@ interface hasField {
collection.hasField('name'); collection.hasField('name');
``` ```
## `collection.updateOptions()`
更改当前 collection 的 options
##### Definition
```ts
interface updateOptions {
(options: CollectionOptions): void;
}
```
##### Examples
```ts
const collection = db.collection({
name: 'tests',
});
collection.updateOptions({
createdAt: true,
updatedAt: true,
sortable: true,
fields: [],
});
```
## `collection.removeField()` ## `collection.removeField()`
移除字段 移除字段
@ -235,3 +208,30 @@ const field = collection.updateField('name1', {
}); });
await field.sync(); await field.sync();
``` ```
## `collection.updateOptions()`
更改当前 collection 的 options
##### Definition
```ts
interface updateOptions {
(options: CollectionOptions): void;
}
```
##### Examples
```ts
const collection = db.collection({
name: 'tests',
});
collection.updateOptions({
createdAt: true,
updatedAt: true,
sortable: true,
fields: [],
});
```

View File

@ -4,27 +4,473 @@ toc: menu
# Field Types # Field Types
## Field - abstract ## Field <Badge>abstract</Badge>
## RelationField - abstract ## RelationField <Badge>abstract</Badge>
## HasOneField ## HasOneField
```ts
interface HasOneFieldOptions {
type: 'hasOne';
/**
* The name of the field to use as the key for the association in the source table. Defaults to the primary
* key of the source table
*/
sourceKey?: string;
/**
* A string or a data type to represent the identifier in the table
*/
keyType?: DataType;
/**
* The alias of this model, in singular form. See also the `name` option passed to `sequelize.define`. If
* you create multiple associations between the same tables, you should provide an alias to be able to
* distinguish between them. If you provide an alias when creating the assocition, you should provide the
* same alias when eager loading and when getting associated models. Defaults to the singularized name of
* target
*/
as?: string | { singular: string; plural: string };
/**
* The name of the foreign key in the target table or an object representing the type definition for the
* foreign column (see `Sequelize.define` for syntax). When using an object, you can add a `name` property
* to set the name of the column. Defaults to the name of source + primary key of source
*/
foreignKey?: string | ForeignKeyOptions;
/**
* What happens when delete occurs.
*
* Cascade if this is a n:m, and set null if it is a 1:m
*
* @default 'SET NULL' or 'CASCADE'
*/
onDelete?: string;
/**
* What happens when update occurs
*
* @default 'CASCADE'
*/
onUpdate?: string;
/**
* Should on update and on delete constraints be enabled on the foreign key.
*/
constraints?: boolean;
foreignKeyConstraint?: boolean;
scope?: AssociationScope;
/**
* If `false` the applicable hooks will not be called.
* The default value depends on the context.
*/
hooks?: boolean;
}
```
## HasManyField ## HasManyField
```ts
interface HasManyFieldOptions {
type: 'hasMany';
/**
* The name of the field to use as the key for the association in the source table. Defaults to the primary
* key of the source table
*/
sourceKey?: string;
/**
* A string or a data type to represent the identifier in the table
*/
keyType?: DataType;
/**
* The alias of this model, in singular form. See also the `name` option passed to `sequelize.define`. If
* you create multiple associations between the same tables, you should provide an alias to be able to
* distinguish between them. If you provide an alias when creating the assocition, you should provide the
* same alias when eager loading and when getting associated models. Defaults to the singularized name of
* target
*/
as?: string | { singular: string; plural: string };
/**
* The name of the foreign key in the target table or an object representing the type definition for the
* foreign column (see `Sequelize.define` for syntax). When using an object, you can add a `name` property
* to set the name of the column. Defaults to the name of source + primary key of source
*/
foreignKey?: string | ForeignKeyOptions;
/**
* What happens when delete occurs.
*
* Cascade if this is a n:m, and set null if it is a 1:m
*
* @default 'SET NULL' or 'CASCADE'
*/
onDelete?: string;
/**
* What happens when update occurs
*
* @default 'CASCADE'
*/
onUpdate?: string;
/**
* Should on update and on delete constraints be enabled on the foreign key.
*/
constraints?: boolean;
foreignKeyConstraint?: boolean;
scope?: AssociationScope;
/**
* If `false` the applicable hooks will not be called.
* The default value depends on the context.
*/
hooks?: boolean;
}
```
## BelongsToField ## BelongsToField
```ts
interface BelongsToFieldOptions {
type: 'belongsTo';
/**
* The name of the field to use as the key for the association in the target table. Defaults to the primary
* key of the target table
*/
targetKey?: string;
/**
* A string or a data type to represent the identifier in the table
*/
keyType?: DataType;
/**
* The alias of this model, in singular form. See also the `name` option passed to `sequelize.define`. If
* you create multiple associations between the same tables, you should provide an alias to be able to
* distinguish between them. If you provide an alias when creating the assocition, you should provide the
* same alias when eager loading and when getting associated models. Defaults to the singularized name of
* target
*/
as?: string | { singular: string; plural: string };
/**
* The name of the foreign key in the target table or an object representing the type definition for the
* foreign column (see `Sequelize.define` for syntax). When using an object, you can add a `name` property
* to set the name of the column. Defaults to the name of source + primary key of source
*/
foreignKey?: string | ForeignKeyOptions;
/**
* What happens when delete occurs.
*
* Cascade if this is a n:m, and set null if it is a 1:m
*
* @default 'SET NULL' or 'CASCADE'
*/
onDelete?: string;
/**
* What happens when update occurs
*
* @default 'CASCADE'
*/
onUpdate?: string;
/**
* Should on update and on delete constraints be enabled on the foreign key.
*/
constraints?: boolean;
foreignKeyConstraint?: boolean;
scope?: AssociationScope;
/**
* If `false` the applicable hooks will not be called.
* The default value depends on the context.
*/
hooks?: boolean;
}
```
## BelongsToManyField ## BelongsToManyField
```ts
interface BelongsToManyFieldOptions {
type: 'belongsToMany';
/**
* The name of the table that is used to join source and target in n:m associations. Can also be a
* sequelize model if you want to define the junction table yourself and add extra attributes to it.
*/
through: ModelType | string | ThroughOptions;
/**
* The name of the foreign key in the join table (representing the target model) or an object representing
* the type definition for the other column (see `Sequelize.define` for syntax). When using an object, you
* can add a `name` property to set the name of the colum. Defaults to the name of target + primary key of
* target
*/
otherKey?: string | ForeignKeyOptions;
/**
* The name of the field to use as the key for the association in the source table. Defaults to the primary
* key of the source table
*/
sourceKey?: string;
/**
* The name of the field to use as the key for the association in the target table. Defaults to the primary
* key of the target table
*/
targetKey?: string;
/**
* Should the join model have timestamps
*/
timestamps?: boolean;
/**
* The unique key name to override the autogenerated one when primary key is not present on through model
*/
uniqueKey?: string;
/**
* A key/value set that will be used for association create and find defaults on the target.
* (sqlite not supported for N:M)
*/
scope?: AssociationScope;
/**
* The alias of this model, in singular form. See also the `name` option passed to `sequelize.define`. If
* you create multiple associations between the same tables, you should provide an alias to be able to
* distinguish between them. If you provide an alias when creating the assocition, you should provide the
* same alias when eager loading and when getting associated models. Defaults to the singularized name of
* target
*/
as?: string | { singular: string; plural: string };
/**
* The name of the foreign key in the target table or an object representing the type definition for the
* foreign column (see `Sequelize.define` for syntax). When using an object, you can add a `name` property
* to set the name of the column. Defaults to the name of source + primary key of source
*/
foreignKey?: string | ForeignKeyOptions;
/**
* What happens when delete occurs.
*
* Cascade if this is a n:m, and set null if it is a 1:m
*
* @default 'SET NULL' or 'CASCADE'
*/
onDelete?: string;
/**
* What happens when update occurs
*
* @default 'CASCADE'
*/
onUpdate?: string;
/**
* Should on update and on delete constraints be enabled on the foreign key.
*/
constraints?: boolean;
foreignKeyConstraint?: boolean;
/**
* If `false` the applicable hooks will not be called.
* The default value depends on the context.
*/
hooks?: boolean;
}
```
## BooleanField
```ts
interface BooleanFieldOptions {
type: 'boolean';
}
```
## StringField ## StringField
```ts
interface StringFieldOptions {
type: 'string';
length?: number;
binary?: boolean;
}
```
## TextField ## TextField
```ts
type TextLength = 'tiny' | 'medium' | 'long';
interface TextFieldOptions {
type: 'text';
length?: TextLength;
}
```
## IntegerField ## IntegerField
```ts
interface IntegerFieldOptions {
type: 'integer';
length?: number;
zerofill?: boolean;
unsigned?: boolean;
}
```
## FloatField ## FloatField
```ts
interface FloatFieldOptions {
type: 'float';
length?: number;
decimals?: number;
}
```
## DoubleField ## DoubleField
```ts
interface DoubleFieldOptions {
type: 'double';
length?: number;
decimals?: number;
}
```
## RealField ## RealField
```ts
interface RealFieldOptions {
type: 'real';
length?: number;
decimals?: number;
}
```
## DecimalField ## DecimalField
```ts
interface DecimalFieldOptions {
type: 'decimal';
precision?: number;
scale?: number;
}
```
## DateField ## DateField
```ts
interface DateFieldOptions {
type: 'date';
}
```
## TimeField ## TimeField
```ts
interface TimeFieldOptions {
type: 'time';
}
```
## JsonField ## JsonField
```ts
interface JsonFieldOptions {
type: 'json';
}
```
## JsonbField ## JsonbField
```ts
interface JsonbFieldOptions {
type: 'jsonb';
}
```
## VirtualField ## VirtualField
```ts
interface VirtualFieldOptions {
type: 'virtual';
}
```
## SortField ## SortField
```ts
interface SortFieldOptions {
type: 'sort';
}
```
## PasswordField ## PasswordField
```ts
interface PasswordFieldOptions {
type: 'password';
}
```
## RadioField ## RadioField
## UidField
```ts
interface RadioFieldOptions {
type: 'radio';
}
```
## UIDField
```ts
interface UIDFieldOptions {
type: 'uid';
}
```
## UUIDField
```ts
interface UUIDFieldOptions {
type: 'uuid';
}
```
## CreatedByField ## CreatedByField
```ts
interface CreatedByFieldOptions {
type: 'createdBy';
}
```
## UpdatedByField ## UpdatedByField
```ts
interface UpdatedByFieldOptions {
type: 'updatedBy';
}
```

View File

@ -5,13 +5,16 @@ toc: menu
# Operators # Operators
## string ## string
- includes
- notIncludes
- eq - eq
- ne - ne
- null - includes
- notNull - notInclude
- empty
- notEmpty
## number ## number
- eq - eq
- ne - ne
- gt - gt
@ -19,32 +22,39 @@ toc: menu
- lt - lt
- lte - lte
- between - between
- null - empty
- notNull - notEmpty
## select ## select
- eq - eq
- ne - ne
- in - in
- notIn - notIn
- null - empty
- notNull - notEmpty
## multipleSelect ## multipleSelect
- match - match
- notMatch - notMatch
- anyOf - anyOf
- noneOf - noneOf
- null - empty
- notNull - notEmpty
## date ## date
- dateOn - dateOn
- dateNotOn - dateNotOn
- dateBefore - dateBefore
- dateAfter - dateAfter
- dateNotBefore - dateNotBefore
- dateNotAfter - dateNotAfter
- null - empty
- notNull - notEmpty
## association ## association
- fieldName.$name
- exists - exists
- notExists - notExists