Learn how to create and configure entity fields, their data types, and advanced customization options in Amplication.
Each entity is composed of fields which define the attributes of that entity, such as name
, email
, or price
. This page will guide you through creating and configuring entity fields within Amplication.
The Entities, Fields, and Relationships features are currently available for projects using Node.js and .NET blueprints.
Navigate to the Entity Screen
Click the Entities icon in the main menu (left toolbar). This will display a list of all entities in your application.
Select an Entity
Click on the entity you want to modify. This will open the Entity’s page, displaying its existing fields.
Add a New Field
Type the name of your field.
Configure Field Details
customerEmail
)You can use Amplication’s AI, Jovu, to simplify field creation for your entities using natural language.
Each field offers optional settings to control its behavior and constraints:
Unique Field
Toggle Unique Field to ensure that each value in this field is unique across all instances of the entity. This is crucial for fields like email addresses or usernames where duplication isn’t allowed.
Required Field
Activate Required Field to make sure that this field must have a value when creating a new entity instance. This prevents incomplete data entries and enforces data integrity for critical attributes.
Searchable
Enable Searchable to allow users to search for entity instances based on the values in this field. Note that field visibility for search results is still controlled by permissions settings.
Select the appropriate data type to define what kind of information your field will store. Each data type is optimized for specific use cases and provides built-in validation and handling.
For short text strings like names or titles. You can set a maximum length to enforce data constraints.
For longer text content like descriptions or notes. You can configure a maximum length.
Specifically for email addresses, ensuring data is in a valid email format.
Optimized for usernames, with a configurable maximum length.
Designed for storing passwords securely. You can set a maximum length.
For integer values. You can select the database field type (Integer or Big Integer) and set minimum and maximum allowed values.
For numbers with decimal places. You can choose the database field type (Decimal or Float), define minimum and maximum values, and set the precision level.
For storing date and time information. You can choose between Local Time and Server Time and specify if it should include both date and time or just the date.
For true/false values.
For storing flexible, schema-less data in JSON format. Excellent for custom fields and adapting to evolving data needs.
For fields that can only take one value from a predefined list of options (single-select dropdown).
Similar to Option Set but allows selecting multiple options from the list (multi-select dropdown).
For storing geographic coordinates.
For storing file metadata. Configure maximum file size, allowed MIME types, and container path for file storage.
For managing user roles and permissions within your application.
Used to establish connections between different entities.
Amplication automatically creates essential fields for every entity:
id
: A unique identifier for each entity instance. By default, it’s a CUID, but you can customize it to UUID, auto-increment integer, or auto-increment big integer.createdAt
: Automatically tracks the creation timestamp of each entity instance.updatedAt
: Automatically updates with the timestamp whenever an entity instance is modified.For developers who need fine-grained control over their fields, Amplication provides Custom Attributes. These attributes allow you to directly leverage Prisma’s powerful schema customization features within the Amplication UI.
Advanced Customization is only available for Node.js blueprints.
You can add field-level attributes (prefixed with @
) to customize individual field properties. These are accessible in the Custom Attributes text field within each field’s settings page.
Common field-level attributes include:
@unique
: Enforce uniqueness for a field@default(...)
: Set a default value@map("column_name")
: Map to a different column name@db.VarChar(200)
)Refer to Prisma’s documentation on field attributes for a comprehensive list of available attributes and functions.
Now that you understand how to work with fields, explore these related topics to build more sophisticated data models:
Learn how to create and manage relationships between entities, including one-to-one, one-to-many, and many-to-many connections.
Dive deeper into entity management, including creating, configuring, and organizing your data models.
Understand how to set up role-based access control and manage permissions for your entity fields.