Skip to main content

Add properties to an entity

Properties are the characteristics of your entities. For example, a Product can have properties like name, description, price...

Syntax

You can add the properties to your entities in the backend.yml file

name: Blog about cats
entities:
📝 Post:
properties:
- name # Short syntax for string type.
- { name: content, type: text } # Property type specified.
- { name: publishedAt, type: date }
- { name: authorEmail, type: email, hidden: true } # Extra options.

Property params

You can pass arguments using the long syntax:

OptionDefaultTypeDescription
type"string"PropTypeThe Property type (text, number, email, location...)
hiddenfalsebooleanIf the property should be hidden in the API response
options-ObjectSpecific options depending on property type
validation-ObjectThe property validators that each request compares against

Property types

Manifest vision of property types goes beyond software development typing and is already built-in for real world usages. For example, the Money PropType is handier than Number for managing amounts as it comes with a currency options and only allows 2 digits after coma.

Each PropType comes with a built-in type validation.

Some of them have specific options. Here is a list of the available types

String

A simple string.

- { name: firstName, type: string }

# Short syntax, same as above.
- firstName

Textarea

Textarea field for medium-size texts.

- { name: description, type: text }

Number

A numerical value.

- { name: age, type: number }

An URL that links to an external page.

- { name: website, type: link }

Money

A money field with a currency. Money properties can have up to 2 digits after coma.

- { name: price, type: money, options: { currency: "EUR" } }
Parameters
OptionDefaultTypeDescription
currencyUSDstringISO 4217 currency code

Date

Basic date field.

- { name: startDate, type: date }

Timestamp

Timestamp field.

- { name: acquiredAt, type: timestamp }

Email

- { name: email, type: email }

Boolean

For any field with a "true or false" value.

- { name: isActive, type: boolean }

File

A file upload. Read more in the file upload doc.

- { name: document, type: file }

Image

An image upload. The different sizes should be provided to generate several sizes of it. Read more in the image upload doc.

- {
name: photo,
type: image,
options:
{ sizes: { small: { height: 90, width: 90 }, large: { width: 200 } } }
}
Parameters
OptionDefaultTypeDescription
sizesthumbnail (80x80) medium (160x160)ImageSizesObjectAn object with each key being the name of each size and with width, height and fit optional props. The fit options works as in Sharp

Password

Password field. Most of the time you do not need to implement passwords manually as authenticable entities have built-in email and password fields to log in.

- { name: password, type: password }
warning

When setting the type as password, Manifest hashes automatically the value before storing it. Passwords should never be stored as clear text.

Choice

A given choice of options.

- { name: sex, type: choice, options: { values: [male, female] } }

# Sequential if the values are ordered in a logical sense..
- {
name: status,
type: choice,
options: { values: [draft, submitted, published], sequential: true },
}
Parameters
OptionDefaultTypeDescription
values(empty)String[]An array of strings representing the available choices
sequentialfalsebooleanSpecifies if the values are ordered in a logical sense

Location

The location type consists in a object with lat and lng coordinates.

- { name: location, type: location }