Data Fields

A Collection is defined by its Data fields and their corresponding Data type.

For example, in our test database (simpledb-abee.restdb.io) we created a Contact Collection with the following Data fields:

fields

Text, email and image are just some of the basic data types supported in restdb.io.

A complete table of the avaliable data types is shown below.

Data types

Data typeDescriptionPropertiesValidationExample
Primary types
textAny charactersingleline, multiline, Markdowninput mask or regular expressionThe quick brown fox
numberIntegersauto incrementinteger123
float_numberFloating pointformula:
{{temp}}/3.14
double3.1456789
moneyFloating pointformula:
{{salary}}*1.25
double 2 decimals1200.00
emailemail addressvalid emailjones@restdb.io
rich textHTML textHTMLBold is the new italic
Date types
dateDateformat:
DD MM YYYY
default: ISO date string
valid date09 22 2015
datetimeDate with timeformat:
DD-MM-YYYY hh:ss
valid date + time09-22-2015 20:36, formats docs
timeTimeformat: hh:ss01.01.1970 + time20:36
Media types
image(s)Imagejpg, png, gifA random image: avatar
file(s)Any filepdficon
Status types
boolBooleantrue or falsefalse
optionPredefined choicesOne or manyOne of the predefined options["ABBA", "Rolling Stones"]
Custom types
JSONA JSON objectValid JSON string / object{"state": "on", "readings": [23.4, 34.2, 900.0]}
Relations to Collections
collectionAn existing Collection in your databaseone item, many items, sub listValid ObjectID["56011d51e1321c7300000010", "55bb3bf70b37951e000001dd"]

Required / Unique fields

All primary Data fields can have a property to define if a Field is required and/or unique. Activating the Field dialog shows the settings for Required and/or Unique.

uniq

Computed fields

Fields of type float and string can be computed using an expression. In the field dialog which pops up when you add or edit a field, fill in an expression in the "Calculated value" box. This expression can use fields from the same record in the collection, numbers or strings. You can also add logic using a ternary expression. For example (revenue>150000)?"premium":"regular" will yield the string "premium" when the record is saved and the revenue is above 150000.

If you have space in the field names, you need to wrap them:

({{net revenue}}>150000)?"premium":"regular"

Calculations are simple using computed fields:

(cost + profit) * 1.20