Collection Configuration Parameters
name - Collection Name
- Type:
string - Required: ✅
- Description: The unique identifier for the collection, which must be unique throughout the application.
- Example:
title - Collection Title
- Type:
string - Required: ❌
- Description: The display title of the collection, used for frontend interface display.
- Example:
migrationRules - Migration Rules
- Type:
MigrationRule[] - Required: ❌
- Description: Processing rules for data migration.
- Example:
inherits - Inherit Collections
- Type:
string[] | string - Required: ❌
- Description: Inherit field definitions from other collections. Supports single or multiple collection inheritance.
- Example:
filterTargetKey - Filter Target Key
- Type:
string | string[] - Required: ❌
- Description: The target key used for filtering queries. Supports single or multiple keys.
- Example:
fields - Field Definitions
- Type:
FieldOptions[] - Required: ❌
- Default Value:
[] - Description: An array of field definitions for the collection. Each field includes information such as type, name, and configuration.
- Example:
model - Custom Model
- Type:
string | ModelStatic<Model> - Required: ❌
- Description: Specify a custom Sequelize model class, which can be either the class name or the model class itself.
- Example:
repository - Custom Repository
- Type:
string | RepositoryType - Required: ❌
- Description: Specify a custom repository class to handle data access logic.
- Example:
autoGenId - Auto-generate ID
- Type:
boolean - Required: ❌
- Default Value:
true - Description: Whether to automatically generate a primary key ID.
- Example:
timestamps - Enable Timestamps
- Type:
boolean - Required: ❌
- Default Value:
true - Description: Whether to enable the
createdAtandupdatedAtfields. - Example:
createdAt - Created At Field
- Type:
boolean | string - Required: ❌
- Default Value:
true - Description: Configuration for the
createdAtfield. - Example:
updatedAt - Updated At Field
- Type:
boolean | string - Required: ❌
- Default Value:
true - Description: Configuration for the
updatedAtfield. - Example:
deletedAt - Soft Delete Field
- Type:
boolean | string - Required: ❌
- Default Value:
false - Description: Configuration for the soft delete field.
- Example:
paranoid - Soft Delete Mode
- Type:
boolean - Required: ❌
- Default Value:
false - Description: Whether to enable soft delete mode.
- Example:
underscored - Underscore Naming
- Type:
boolean - Required: ❌
- Default Value:
false - Description: Whether to use the underscore naming style.
- Example:
indexes - Index Configuration
- Type:
ModelIndexesOptions[] - Required: ❌
- Description: Database index configuration.
- Example:
Field Parameter Configuration
NocoBase supports multiple field types, all defined based on the FieldOptions union type. Field configuration includes basic properties, data type-specific properties, relationship properties, and frontend rendering properties.
Basic Field Options
All field types inherit from BaseFieldOptions, providing common field configuration capabilities:
Example:
name - Field Name
- Type:
string - Required: ❌
- Description: The column name of the field in the database, which must be unique within the collection.
- Example:
hidden - Hide Field
- Type:
boolean - Default Value:
false - Description: Whether to hide this field by default in lists and forms.
- Example:
validation - Validation Rules
- Type:
ValidationOptions<T> - Description: Use Joi to define server-side validation rules.
- Example:
allowNull - Allow Null Values
- Type:
boolean - Default Value:
true - Description: Controls whether the database allows writing
NULLvalues. - Example:
defaultValue - Default Value
- Type:
any - Description: The default value for the field, used when a record is created without providing a value for this field.
- Example:
unique - Unique Constraint
- Type:
boolean | string - Default Value:
false - Description: Whether the value must be unique. A string can be used to specify the constraint name.
- Example:
primaryKey - Primary Key
- Type:
boolean - Default Value:
false - Description: Declares this field as the primary key.
- Example:
autoIncrement - Auto-increment
- Type:
boolean - Default Value:
false - Description: Enables auto-incrementing (only applicable to numeric fields).
- Example:
field - Database Column Name
- Type:
string - Description: Specifies the actual database column name (consistent with Sequelize's
field). - Example:
comment - Database Comment
- Type:
string - Description: A comment for the database field, used for documentation purposes.
- Example:
title - Display Title
- Type:
string - Description: The display title for the field, commonly used in the frontend interface.
- Example:
description - Field Description
- Type:
string - Description: Descriptive information about the field to help users understand its purpose.
- Example:
interface - Interface Component
- Type:
string - Description: The recommended frontend interface component for the field.
- Example:
Field Type Interfaces
type: 'string' - String Field
- Description: Used to store short text data. Supports length limits and automatic trimming.
- Database Type:
VARCHAR - Specific Properties:
length: String length limit.trim: Whether to automatically remove leading and trailing spaces.
Example:
type: 'text' - Text Field
- Description: Used to store long text data. Supports different text types in MySQL.
- Database Type:
TEXT,MEDIUMTEXT,LONGTEXT - Specific Properties:
length: MySQL text length type (tiny/medium/long).
Example:
Numeric Types
type: 'integer' - Integer Field
- Description: Used to store integer data. Supports auto-increment and primary key.
- Database Type:
INTEGER
Example:
type: 'bigInt' - Big Integer Field
- Description: Used to store large integer data, with a range greater than
integer. - Database Type:
BIGINT
Example:
type: 'float' - Float Field
- Description: Used to store single-precision floating-point numbers.
- Database Type:
FLOAT - Specific Properties:
precision: The total number of digits.scale: The number of decimal places.
Example:
type: 'double' - Double-precision Float Field
- Description: Used to store double-precision floating-point numbers, which have higher precision than
float. - Database Type:
DOUBLE - Specific Properties:
precision: The total number of digits.scale: The number of decimal places.
Example:
type: 'real' - Real Field
- Description: Used to store real numbers; database-dependent.
- Database Type:
REAL - Specific Properties:
precision: The total number of digits.scale: The number of decimal places.
Example:
type: 'decimal' - Decimal Field
- Description: Used to store exact decimal numbers, suitable for financial calculations.
- Database Type:
DECIMAL - Specific Properties:
precision: The total number of digits.scale: The number of decimal places.
Example:
Boolean Types
type: 'boolean' - Boolean Field
- Description: Used to store true/false values, typically for on/off states.
- Database Type:
BOOLEANorTINYINT(1)
Example:
type: 'radio' - Radio Field
- Description: Used to store a single selected value, typically for binary choices.
- Database Type:
BOOLEANorTINYINT(1)
Example:
Date and Time Types
type: 'date' - Date Field
- Description: Used to store date data without time information.
- Database Type:
DATE - Specific Properties:
timezone: Whether to include timezone information.
Example:
type: 'time' - Time Field
- Description: Used to store time data without date information.
- Database Type:
TIME - Specific Properties:
timezone: Whether to include timezone information.
Example:
type: 'datetimeTz' - Datetime with Timezone Field
- Description: Used to store date and time data with timezone information.
- Database Type:
TIMESTAMP WITH TIME ZONE - Specific Properties:
timezone: Whether to include timezone information.
Example:
type: 'datetimeNoTz' - Datetime without Timezone Field
- Description: Used to store date and time data without timezone information.
- Database Type:
TIMESTAMPorDATETIME - Specific Properties:
timezone: Whether to include timezone information.
Example:
type: 'dateOnly' - Date Only Field
- Description: Used to store data containing only the date, without time.
- Database Type:
DATE - Example:
type: 'unixTimestamp' - Unix Timestamp Field
- Description: Used to store Unix timestamp data.
- Database Type:
BIGINT - Specific Properties:
epoch: The epoch time.
Example:
JSON Types
type: 'json' - JSON Field
- Description: Used to store data in JSON format, supporting complex data structures.
- Database Type:
JSONorTEXT - Example:
type: 'jsonb' - JSONB Field
- Description: Used to store data in JSONB format (PostgreSQL-specific), which supports indexing and querying.
- Database Type:
JSONB(PostgreSQL) - Example:
Array Types
type: 'array' - Array Field
- Description: Used to store array data, supporting various element types.
- Database Type:
JSONorARRAY - Specific Properties:
dataType: Storage type (json/array).elementType: Element type (STRING/INTEGER/BOOLEAN/JSON).
Example:
type: 'set' - Set Field
- Description: Used to store set data, which is similar to an array but with a uniqueness constraint.
- Database Type:
JSONorARRAY - Specific Properties:
dataType: Storage type (json/array).elementType: Element type (STRING/INTEGER/BOOLEAN/JSON).
Example:
Identifier Types
type: 'uuid' - UUID Field
- Description: Used to store unique identifiers in UUID format.
- Database Type:
UUIDorVARCHAR(36) - Specific Properties:
autoFill: Automatically fills the value.
Example:
type: 'nanoid' - Nanoid Field
- Description: Used to store short unique identifiers in Nanoid format.
- Database Type:
VARCHAR - Specific Properties:
size: Length of the ID.customAlphabet: Custom character set.autoFill: Automatically fills the value.
Example:
type: 'uid' - Custom UID Field
- Description: Used to store unique identifiers in a custom format.
- Database Type:
VARCHAR - Specific Properties:
prefix: A prefix for the identifier.pattern: A validation pattern.
Example:
type: 'snowflakeId' - Snowflake ID Field
- Description: Used to store unique identifiers generated by the Snowflake algorithm.
- Database Type:
BIGINT - Example:
Functional Fields
type: 'password' - Password Field
- Description: Used to store encrypted password data.
- Database Type:
VARCHAR - Specific Properties:
length: Hash length.randomBytesSize: Size of the random bytes.
Example:
type: 'encryption' - Encryption Field
- Description: Used to store encrypted sensitive data.
- Database Type:
VARCHAR - Example:
type: 'virtual' - Virtual Field
- Description: Used to store calculated virtual data that is not stored in the database.
- Database Type: None (virtual field)
- Example:
type: 'context' - Context Field
- Description: Used to read data from the runtime context (e.g., current user information).
- Database Type: Determined by
dataType. - Specific Properties:
dataIndex: Data index path.dataType: Data type.createOnly: Set only on creation.
Example:
Relationship Fields
type: 'belongsTo' - Belongs To Relationship
- Description: Represents a many-to-one relationship, where the current record belongs to another record.
- Database Type: Foreign key field
- Specific Properties:
target: Target collection name.foreignKey: Foreign key field name.targetKey: Target key field name in the target collection.onDelete: Cascade action on delete.onUpdate: Cascade action on update.constraints: Whether to enable foreign key constraints.
Example:
type: 'hasOne' - Has One Relationship
- Description: Represents a one-to-one relationship, where the current record has one related record.
- Database Type: Foreign key field
- Specific Properties:
target: Target collection name.foreignKey: Foreign key field name.sourceKey: Source key field name in the source collection.onDelete: Cascade action on delete.onUpdate: Cascade action on update.constraints: Whether to enable foreign key constraints.
Example:
type: 'hasMany' - Has Many Relationship
- Description: Represents a one-to-many relationship, where the current record has multiple related records.
- Database Type: Foreign key field
- Specific Properties:
target: Target collection name.foreignKey: Foreign key field name.sourceKey: Source key field name in the source collection.sortBy: Sorting field.sortable: Whether the field is sortable.onDelete: Cascade action on delete.onUpdate: Cascade action on update.constraints: Whether to enable foreign key constraints.
Example:
type: 'belongsToMany' - Belongs To Many Relationship
- Description: Represents a many-to-many relationship, connecting two collections through a junction table.
- Database Type: Junction table
- Specific Properties:
target: Target collection name.through: Junction table name.foreignKey: Foreign key field name.otherKey: The other foreign key in the junction table.sourceKey: Source key field name in the source collection.targetKey: Target key field name in the target collection.onDelete: Cascade action on delete.onUpdate: Cascade action on update.constraints: Whether to enable foreign key constraints.
Example:

