What are Smart Fields?
In traditional development, a database only understands primitive data types, such as strings, numbers, or booleans. It does not know if a string is a password, a country code, or a monetary amount. Programmers have to write custom code to validate, encrypt, or manipulate these fields.
API Now! replaces this manual work with Smart Fields (also known as Data Semantics).
Smart Fields are metadata tags you apply to your database properties. They tell the Serverless Engine what a field means in the real world. Once tagged, the engine automatically attaches the appropriate database constraints, input validations, security rules, and query behaviors.
Key Benefits of Smart Fields
Section titled “Key Benefits of Smart Fields”By tagging your data semantics, the platform handles complex engineering tasks automatically:
Bulletproof Security
Section titled “Bulletproof Security”Applying the Password tag tells the engine to automatically salt and hash the value before storing it. It also automatically hides the password from all read API requests. Security is enforced at the core database level, so your frontend applications can never accidentally expose it.
Automatic Auditing & Trash Bins
Section titled “Automatic Auditing & Trash Bins”Tagging fields with lifecycle semantics like CreatedTimestamp or UpdatedTimestamp tells the database to automatically write timestamps when records are added or changed. Tagging an entity with SoftDelete automatically changes “Delete” actions to flag records as “hidden” in a Recycle Bin, rather than permanently purging them.
Input Validation
Section titled “Input Validation”Fields like Email, Phone, and Country automatically reject invalid formats on the API gateway level before they can pollute your database.
Formula-Based Logic
Section titled “Formula-Based Logic”Semantics like Calculated allow you to define math formulas (e.g., price * taxRate), and Derived lets you concatenate fields (e.g., firstName + " " + lastName) directly within the database layer.
Core Categories
Section titled “Core Categories”Smart Fields are organized into logical groups based on their business behavior:
- Identity & Access: Define who your users are (
User), how they sign in (Username,Password), and their permissions (UserRole). - Ownership & Auditing: Link records to their creator (
CreatedBy,ResourceOwnerIdentifier) to enforce row-level security. - Time & Versioning: Track when entries change (
CreatedTimestamp,UpdatedTimestamp,Version). - Contact Info: Automate communication fields (
Email,Phone,URL). - Business & Location: Enforce formatting for financial values (
Currency), catalog codes (SKU), and geographical coordinates (Address,GeospatialCoordinates). - Automation: Set up database-level calculations (
Calculated,Derived).
How to Apply Smart Fields
Section titled “How to Apply Smart Fields”- Open the Domain Modeler.
- Select or create an Entity (e.g.,
Product), and add a Property (e.g.,price). - In the property configuration form, locate the Smart Field (Semantic Type) dropdown.
- Select the matching tag (e.g., select
Currencyfor your price property). - Save your changes. The platform will automatically reconfigure your PostgreSQL database columns and API validation schemas to match the selected behavior.