Skip to content

Latest commit

 

History

History
157 lines (105 loc) · 3.86 KB

properties.md

File metadata and controls

157 lines (105 loc) · 3.86 KB
id
properties

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:

Option Default Type Description
type "string" PropType The Property type (text, number, email, location...)
hidden false boolean If the property should be hidden in the API response
options - Object Specific options depending on type

Property types

Each property has a type that represents real-world usages. Some of them have specific options.

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 }

Link

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
Option Default Type Description
currency USD string ISO 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 }

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
Option Default Type Description
values (empty) String[] An array of strings representing the available choices
sequential false boolean Specifies 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 }