Skip to main content
The API uses type for Database and app for Space. See Terminology.

Update entity collection Field

Add already existing Entities to an entity collection Field by providing their fibery/id. Remove Entities from the collection in a similar way. Get fibery/id either via API or by opening the relevant Entity on UI and exploring the command response in browser’s Network tab. Cricket/Player Database used as an example
Field nameField type
fibery/idfibery/uuid
Cricket/Former Teamsentity collection Field

Add

Add two existing Teams to Player’s “Former Teams” entity collection Field (if team already exists in the collection then team will be ignored during addition):
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
  method: 'POST',
  headers: {
    'Authorization': 'Token YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    command: 'fibery.entity/add-collection-items',
    args: {
      type: 'Cricket/Player',
      field: 'Cricket/Former Teams',
      entity: {
        '216c2a00-9752-11e9-81b9-4363f716f666': [
          '0a3ae1c0-97fa-11e9-81b9-4363f716f666',
          '17af8db0-97fa-11e9-81b9-4363f716f666'
        ]
      }
    }
  })
});
const data = await response.json();
Response:
{
  "success": true,
  "result": "ok"
}

Remove

Remove two Teams from Player’s “Former Teams” entity collection Field (if team doesn’t exist in the collection then team will be ignored during removing):
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
  method: 'POST',
  headers: {
    'Authorization': 'Token YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    command: 'fibery.entity/remove-collection-items',
    args: {
      type: 'Cricket/Player',
      field: 'Cricket/Former Teams',
      entity: {
        '216c2a00-9752-11e9-81b9-4363f716f666': [
          '0a3ae1c0-97fa-11e9-81b9-4363f716f666',
          '17af8db0-97fa-11e9-81b9-4363f716f666'
        ]
      }
    }
  })
});
const data = await response.json();
Response:
{
  "success": true,
  "result": "ok"
}

Set

Replace two Teams from Player’s “Former Teams” entity collection Field with new team.
Replace means deletion of any existing collection items and adding new items.
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
  method: 'POST',
  headers: {
    'Authorization': 'Token YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    command: 'fibery.entity/set-collection-items',
    args: {
      type: 'Cricket/Player',
      field: 'Cricket/Former Teams',
      entity: {
        '216c2a00-9752-11e9-81b9-4363f716f666': [
          '02007d5e-b3d9-44c3-83de-6b562870f120'
        ]
      }
    }
  })
});
const data = await response.json();
Response:
{
  "success": true,
  "result": "ok"
}

Reset

Resets “Former Teams” entity collection Field with new team.
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
  method: 'POST',
  headers: {
    'Authorization': 'Token YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    command: 'fibery.entity/reset-collection-items',
    args: {
      type: 'Cricket/Player',
      field: 'Cricket/Former Teams',
      entity: '216c2a00-9752-11e9-81b9-4363f716f666'
    }
  })
});
const data = await response.json();
Response:
{
  "success": true,
  "result": "ok"
}

Update single-select and multi-select Fields

A single-select Field is an entity Field — each option is an Entity with its own fibery/id. Update it via fibery.entity/update, the same way as any entity Field. A multi-select Field is an entity collection Field — each option is an Entity with its own fibery/id. Update it via collection commands (add-collection-items, remove-collection-items, set-collection-items, reset-collection-items), the same way as any entity collection Field. Get an option’s fibery/id either via API or by opening the Entity on UI and exploring the command response in browser’s Network tab. Cricket/Player Database used as an example
Field nameField type
Cricket/Batting Handsingle-select
Cricket/Playing Rolesmulti-select

Set single-select Field

Set Cricket/Batting Hand on a Player:
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
  method: 'POST',
  headers: {
    'Authorization': 'Token YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    command: 'fibery.entity/update',
    args: {
      type: 'Cricket/Player',
      entity: {
        'fibery/id': '20f9b920-9752-11e9-81b9-4363f716f666',
        'Cricket/Batting Hand': { 'fibery/id': 'b0ed1370-9747-11e9-9f03-fd937c4ecf3b' }
      }
    }
  })
});
const data = await response.json();
Response:
{
  "success": true,
  "result": {
    "fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666"
  }
}

Add options to multi-select Field

Add two options to Cricket/Playing Roles on a Player:
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
  method: 'POST',
  headers: {
    'Authorization': 'Token YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    command: 'fibery.entity/add-collection-items',
    args: {
      type: 'Cricket/Player',
      field: 'Cricket/Playing Roles',
      entity: {
        '20f9b920-9752-11e9-81b9-4363f716f666': [
          'c1d8e4b0-9747-11e9-9f03-fd937c4ecf3b',
          'c1d9f5c0-9747-11e9-9f03-fd937c4ecf3b'
        ]
      }
    }
  })
});
const data = await response.json();
Response:
{
  "success": true,
  "result": "ok"
}
Remove, replace, or reset multi-select options the same way — see Update entity collection Field for fibery.entity/remove-collection-items, fibery.entity/set-collection-items, and fibery.entity/reset-collection-items.