Skip to main content

Create an entity

An entity is a model of objects linked to real-world concepts. Creating an entity in manifest generates CRUD endpoints that can be used by the REST API or the SDK.

All entities are located in the backend.yml file under the entities property.

There are 2 types of entities in Manifest: Collections and Singles. Collections are multiple instances of similar data, stored as a list. E.g., users, customers, videos, etc. Singles are unique, standalone data that are singular in nature. E.g., home content, about content, settings, logo...

Collections

Let's see a simple example:

manifest/backend.yml
name: A pet app

entities:
Cat 😺:
properties:
- name
Dog 🐶:
properties:
- name

This file will generate the Cat and Dog entity both with a name property. You can now add your own pets through the admin panel!

Seed

Dummy data is crucial for app development and testing. You can generate dummy data for all your entities with the simple command:

npm run manifest:seed
warning

The seed replaces the previous data by the new one and thus should never be used in production.

Collection entity params

You can pass different arguments to configure your entities. Example:

entities:
Member 👤:
seedCount: 200
mainProp: lastName
properties:
- firstName
- lastName
- email
OptionDefaultTypeDescription
authenticablefalsebooleanWhether the entity is authenticable or not
mainPropfirst string fieldstringIdentifier prop. Used widely on the admin panel
nameSingularsingular lower case namestringThe singular lowercase name of your entity. Used widely on the admin panel.
namePluralplural lower case namestringThe plural lowercase name of your entity. Used widely on the admin panel Default: plural lowercase name.
policies-PoliciesThe access control policies of your entity
properties[]ArrayThe properties of your entity
seedCount50numberthe number of entities to seed when running the seed command.
slugplural dasherized namestringThe kebab-case slug of the entity that will define API endpoints.

Singles

Single entities differ a bit from collections. A single entity is singular in nature, and there can be only one record of them. Examples are website dynamic elements, pages, standalone content or settings. They do not have relations.

On single entities Create and Delete CRUD actions are disabled. Thus, the REST API endpoints for single entities are different.

ContactPage:
single: true
slug: contact
properties:
- { name: title, type: string }
- { name: content, type: text }
- { name: image, type: image }
validation:
title: { required: true }

Single entity params

You can pass different arguments to configure your single entities. Example:

entities:
Member 👤:
seedCount: 200
mainProp: lastName
properties:
- firstName
- lastName
- email
OptionDefaultTypeDescription
nameSingularsingular lower case namestringThe singular lowercase name of your entity. Used widely on the admin panel.
policies-PoliciesThe access control policies of your entity
properties[]ArrayThe properties of your entity
slugplural dasherized namestringThe kebab-case slug of the entity that will define API endpoints.