Basic schema structure
Entity schemas are defined in JSON files in your project’s entities directory. By default, this isbase44/entities/, but you can customize the path in your project configuration. The filename determines the entity name. For example, Task.json creates a Task entity.
Here’s an entity schema template:
Built-in fields
Every entity record automatically includes the following fields. Don’t define fields with these names in your schema.
Internal fields aren’t returned in API responses but can be referenced in security rules.
Schema fields
string
String identifier for the entity.
string
required
Must be
"object".string
User-friendly display name.
string
Description of what the entity represents.
object
required
Object containing your field definitions. Each field has a
type and optional
validation rules.Field types
Entities support various field types to define different kinds of data you can store:string, integer, number, boolean, array, and object.
Each field inside properties requires a type. Based on the type, you can add validation options.
String fields
String fields support these options:minLength/maxLength: Control minimum and maximum character count.pattern: Regular expression for custom validation.format: Predefined formats. Supported values:"date""date-time""time""email""uri""hostname""ipv4""ipv6""uuid"
enum: Restrict to specific allowed values. Define as an array:["value1", "value2", "value3"].default: Default value if none provided.
Integer fields
Integer fields support these options:minimum/maximum: Set inclusive lower/upper bounds.default: Default value if none provided.
Number fields
Number fields support these options:minimum/maximum: Set inclusive lower/upper bounds.default: Default value if none provided.
Boolean fields
Boolean fields support these options:default: Default value if none provided.
Array fields
Array fields support these options:items: Define the type/schema for array elements.default: Default array value if none provided.
Object fields
Object fields support these options:properties: Define the fields within the object.required: List of required property names.
Required fields
Specify which fields must be provided:Uniqueness
Base44 entities don’t support unique constraints. A property that isn’t part of the schema format, such asunique_fields, is stored with your schema and ignored.
To avoid duplicate records, check for an existing record in a backend function before you create a new one. A check like this narrows the window for duplicates but doesn’t close it. To make sure only one user succeeds, use the claim pattern in concurrent updates.
Concurrent updates
Base44 doesn’t lock records or run transactions across several records. When 2 users or processes change the same data at the same time, each write is applied on its own. This section covers which updates are atomic, how to claim a record safely, and what to expect from calls that write several records.Claiming a record safely
To make sure only one user can claim an existing record, such as a task or a booking slot, callupdateMany() with that single record’s id and the conditions that must still be true. The update is applied only if those conditions still match at the moment of the write, so when 2 users try at the same time, only one of them succeeds. Check updated in the response to see whether yours did.
Writing several records
bulkCreate(), bulkUpdate(), updateMany(), deleteMany() and upsert() aren’t transactions. Each record is written on its own, so if a call fails partway, the records already written stay written. Design these calls so they’re safe to run again, for example by filtering out records that were already updated.
Concurrent upsert() calls with the same key can create duplicate records.
Complete example
Here’s a complete entity schema:Deploying entities
After defining your entity schema, deploy it to Base44 usingentities push. Entities are also deployed automatically when you run the deploy command to deploy your entire project.
Once deployed, you can interact with your entities using the SDK’s entities module. The entity name in your schema must match exactly how you access it in the SDK, including capitalization. For example, if your schema has "name": "Task", you must access it as base44.entities.Task.list().
Deployed entity schemas can be viewed in the dashboard in the Data section.
See also
- User Schema: Special built-in entity for user authentication
- Security: Configure row-level security rules for entities
- Project Structure: How entity schemas fit into your project