Guide
Field is a part of Type (Database). Learn more about Fields in the guide.
In the interface, Type = Database, App = Space. To find out why, check Terminology.
Create Field
Primitive Field
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
await fibery.field.createBatch([
{
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/Salary',
'fibery/type': 'fibery/int',
'fibery/meta': {
'fibery/readonly?': false,
'fibery/default-value': 1000,
'ui/number-unit': 'USD'
}
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "Cricket/Salary",
"fibery/type": "fibery/int",
"fibery/meta": {
"fibery/readonly?": false,
"fibery/default-value": 1000,
"ui/number-unit": "USD"
}
}
}
]
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}
Primitive Field types
Field type | Example | Comments |
|---|
fibery/int
| 42 | |
fibery/decimal
| 0.33 | |
fibery/bool
| true | |
fibery/text
| Don't panic | Up to 1k characters. Can be styled using ui/type meta flag: text | email | phone | url
|
fibery/email
| contact@megadodo.com
| This field type is deprecated. Use a "fibery/text" field with ui/type meta set to "email": {
"ui/type": "email"
}
|
fibery/emoji
| 🏏 | |
fibery/date
| 1979-10-12 | |
fibery/date-time
| 2019-06-24T12:25:20.812Z | |
fibery/date-range
| {
"start": "2019-06-27",
"end": "2019-06-30"
}
| |
fibery/date-time-range
| {
"start": "2019-06-18T02:40:00.000Z",
"end": "2019-07-25T11:40:00.000Z"
}
| |
fibery/location
| {
"longitude": 2.349606,
"latitude": 48.890764,
"fullAddress": "Métro Marcadet Poissonniers, 67 boulevard Barbès, Paris, 75018, France",
"addressParts": {
"city": "Paris",
"country": "France"
}
}
| All address parts are optional. Check supported values in Location field |
fibery/uuid
| acb5ef80-9679-11e9-bc42-526af7764f64 | |
fibery/rank
| 1000 | |
fibery/json-value
| { "paranoid?": true }
| |
Command parameters
Parameter (required in bold) | Description | Example |
|---|
fibery/holder-type
| Holder Type name in ${space}/${name} format | Cricket/Player
|
fibery/name
| Field name in ${space}/${name} format. | Cricket/Salary
|
fibery/type
| One of the primitive Field types above or a Type for a one-way relation. | fibery/int
|
meta.fibery/readonly? | If users are able to change value from UI | true |
meta.fibery/default-value | The value automatically set when a new entity is created | "(empty)" |
meta.fibery/unique? | Makes field values to be unique across the whole Database Only one of unique flags can be used at a time as fibery/unique? and fibery/case-insensitive-text-unique?
are mutually exclusive | true |
meta.fibery/case-insensitive-text-unique? | makes field values to be unique case insensitive across whole Database | true |
Create unique case insensitive Text Field:
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
await fibery.field.createBatch([
{
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/SSN',
'fibery/type': 'fibery/text',
'fibery/meta': {
'fibery/readonly?': false,
'fibery/case-insensitive-text-unique?': true
}
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "SSN",
"fibery/type": "fibery/text",
"fibery/meta": {
"fibery/readonly?": false,
"fibery/case-insensitive-text-unique?": true
}
}
}
]
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}
Create unique Int Field:
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
await fibery.field.createBatch([
{
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/Jersey Number',
'fibery/type': 'fibery/int',
'fibery/meta': {
'fibery/readonly?': false,
'fibery/unique?': true
}
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "Cricket/Jersey Number",
"fibery/type": "fibery/int",
"fibery/meta": {
"fibery/readonly?": false,
"fibery/unique?": true
}
}
}
]
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}
Relation (entity [collection] Field)
To create a relation between two Types, we create a pair of entity [collection] Fields and connect them with a unique identifier.
The relation is to-one by default. Set entity Field's meta.fibery/collection? to true for to-many relation.
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
// The unofficial client is closer to UI than to API here.
// Note the missing 'fibery/' namespace in Field type name and meta parameter —
// these things are unique to the client.
await fibery.field.createBatch([
{
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/Current Team',
'fibery/type': 'relation',
meta: {
to: 'Cricket/Team',
toName: 'Cricket/Current Roster',
isFromMany: true,
isToMany: false
}
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "Cricket/Current Team",
"fibery/type": "Cricket/Team",
"fibery/meta": {
"fibery/relation": "d9e9ec34-9685-11e9-8550-526af7764f64"
}
}
},
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Team",
"fibery/name": "Cricket/Current Roster",
"fibery/type": "Cricket/Player",
"fibery/meta": {
"fibery/collection?": true,
"fibery/relation": "d9e9ec34-9685-11e9-8550-526af7764f64"
}
}
}
]
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}
Command parameters
Parameter (required in bold) | Description | Example |
|---|
fibery/holder-type
| Holder Type name in ${space}/${name} format | Cricket/Player
|
fibery/name
| Field name in ${space}/${name} format. | Cricket/Current Team
|
fibery/type
| Related Type name in ${space}/${name} format | Cricket/Team
|
meta.fibery/relation | UUID shared between the pair of Fields. | d9e9ec34-96... |
meta.fibery/collection? | true for to-many relation (entity collection Field)
| true |
meta.fibery/readonly? | If users are able to change value from UI | true |
Single-select Field
A single-select Field is not what it seems to be. Actually, every single-select option is an Entity of a newly created special Type.
This way unlocks 'name on UI + value in Formula' scenario (think Self conviction → 0.01 in GIST) and enables an easy transition to a fully functional Type.
To create a single-select Field we should:
Create a new enum Type
Create a Field of the newly created enum Type
Create an Entity for each single-select option
Make the selection required and set the default value
The new enum Type name is built using this format: ${space}/${field}_${app}/${holder-type}.
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
// The unofficial client is closer to UI than to API here.
// Note the missing 'fibery/' namespace in Field type name and meta parameter —
// these things are unique to the client.
await fibery.field.createBatch([
{
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/Batting Hand',
'fibery/type': 'single-select',
meta: {
options: [
{ name: 'Right' },
{ name: 'Left' }
]
}
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.command/batch",
"args": {
"commands": [
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.enum/create",
"args": {
"fibery/name": "Cricket/Batting Hand_Cricket/Player"
}
},
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "Cricket/Batting Hand",
"fibery/type": "Cricket/Batting Hand_Cricket/Player"
}
}
]
}
},
{
"command": "fibery.entity/create",
"args": {
"type": "Cricket/Batting Hand_Cricket/Player",
"entity": {
"enum/name": "Right",
"fibery/id": "4a3ffb10-9747-11e9-9def-016e5ea5e162",
"fibery/rank": 0
}
}
},
{
"command": "fibery.entity/create",
"args": {
"type": "Cricket/Batting Hand_Cricket/Player",
"entity": {
"enum/name": "Left",
"fibery/id": "4a402220-9747-11e9-9def-016e5ea5e162",
"fibery/rank": 1000000
}
}
},
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/set-meta",
"args": {
"name": "Cricket/Batting Hand",
"holder-type": "Cricket/Player",
"key": "fibery/default-value",
"value": {
"fibery/id": "4a3ffb10-9747-11e9-9def-016e5ea5e162"
}
}
},
{
"command": "schema.field/set-meta",
"args": {
"name": "Cricket/Batting Hand",
"holder-type": "Cricket/Player",
"key": "fibery/required?",
"value": true
}
}
]
}
}
]
}
}
'
Result (cURL):
{
"success": true,
"result": [
{
"success": true,
"result": "ok"
},
{
"success": true,
"result": {
"fibery/id": "4a3ffb10-9747-11e9-9def-016e5ea5e162",
"fibery/public-id": "1",
"enum/name": "Right",
"fibery/rank": 0
}
},
{
"success": true,
"result": {
"fibery/id": "4a402220-9747-11e9-9def-016e5ea5e162",
"fibery/public-id": "2",
"enum/name": "Left",
"fibery/rank": 1000000
}
},
{
"success": true,
"result": "ok"
}
]
}
Rich text Field
In Fibery, every Rich Text Field instance is, in fact, a collaborative document.
It means that for each Entity with N rich text Fields Fibery automatically creates N documents. Each of these documents is stored in Document Storage and is connected to its Entity through an auxiliary Collaboration~Documents/Document Entity:
Entity --- (magic) ---> Collab Doc/Document --- (fibery/secret) ---> Document in Storage
So to create a rich text Field we just connect our Type with Collaboration~Documents/Document Type. Type Collaboration~Documents/Document has a special property, namely, the entities of this Type inherit access from their Parent Entity. To indicate that Parent-Child relationship we pass fibery/entity-component? meta flag, but only for ordinary Fields (e.g. not Lookup and not Formula)
Selecting and updating a rich text Field is a two-step process:
Get fibery/secret of the related Document.
Work with this Document via api/documents Storage endpoint.
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
// The unofficial client is closer to UI than to API here.
// Note the missing 'fibery/' namespace in Field type name and meta parameter —
// these things are unique to the client.
await fibery.field.createBatch([
{
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/Bio',
'fibery/type': 'Collaboration~Documents/Document',
'fibery/meta': {
'fibery/entity-component?': true,
}
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "Cricket/Bio",
"fibery/type": "Collaboration~Documents/Document",
"fibery/meta": {
"fibery/entity-component?": true,
},
}
}
]
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}
Rename Field
At the moment, renaming a Field breaks related Views, Formulas and Reports. After you rename a Field, make sure to update the related configs.
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
await fibery.field.renameBatch([
{
'holder-type': 'Cricket/Player',
'from-name': 'Cricket/Position',
'to-name': 'Cricket/Role'
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/rename",
"args": {
"holder-type": "Cricket/Player",
"from-name": "Cricket/Position",
"to-name": "Cricket/Role"
}
}
]
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}
Command parameters
Parameter (required in bold) | Description | Example |
|---|
holder-type
| Holder Type name in ${space}/${name} format | Cricket/Player
|
from-name
| Current Field name in ${space}/${name} format | Cricket/Position
|
to-name
| New Field name in ${space}/${name} format | Cricket/Role
|
Delete Field
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
await fibery.field.deleteBatch([
{
'holder-type': 'Cricket/Player',
'name': 'Cricket/Role',
'delete-values?': true
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/delete",
"args": {
"holder-type": "Cricket/Player",
"name": "Cricket/Role",
"delete-values?": true
}
}
]
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}
Command parameters
Parameter (required in bold) | Default | Description | Example |
|---|
holder-type
| | Holder Type name in ${space}/${name} format | Cricket/Player
|
name
| | Field name in ${space}/${name} format | Cricket/Role
|
delete-values?
| false | See the behavior in the table below | true |
To remove a relation, delete both entity [collection] Fields within the same fibery.schema/batch command.
delete-values? parameter behavior
| delete-values?
|
false | true |
Field type | Empty primitive Field | Field is deleted | Field is deleted |
Non-empty primitive Field | Error is thrown | Field and values are deleted |
Empty entity [collection] Field | Field is deleted | Field is deleted |
Non-empty entity [collection] Field | Error is thrown | Field and links (but not related Entities) are deleted
|
FAQ
Is there a way to modify the meta.fibery readonly? value? Is there any way to convert a field away from read-only?
Use "command": "schema.field/set-meta".So, if you can set meta readonly? value to false, that has to work.
How to create header anchor links in a script?
If you retrieve the doc content as JSON (instead of markdown) you will find that paragraphs have attributes, including the ‘level’ and a GUID.
The level will tell you if it’s a header. and anchors are formed by adding the GUID property to the base URL.