Skip to content

Entity Structure

An entity represents a data model or table within the system, encapsulating its structure, fields, and relationships with other entities. Entities are fundamental data structures in the application, which are allowed to save, retrieve, and manipulate data records.

To create an entity from scratch, it’s needed to define its properties, fields, and relationships. Below are the key properties of an entity:

FieldTypeDescription
auditedbooleanIndicates if changes to the entity’s records should be logged for auditing purposes.
read_onlybooleanWhen true, prevents any modification to the entity’s records through entire system.
importablebooleanIndicates whether records for this entity can be imported from an external source.
show_on_menubooleanDetermines if this entity will appear as an item in the main navigation menu.
schemastringDatabase schema where the entity’s table is located. (internal entities will use public)
datasourcestringIdentifier for the database connection that this entity should use.
object_namestringInternal, technical name of the entity object, often corresponding to the database table name.
object_labelstringHuman-readable name for the entity, used for display purposes in the user interface.
fieldsArray<Field>Array of objects that define the attributes of the entity.
list_asArray<string>Array of field names to be displayed by default in list views for this entity.
relationshipsArray<Relationship>Array of objects, each defining a relationship (e.g., many-to-one) with another entity.

While working with API calls, it is essential to understand the structure of the payload when creating or updating an entity. Below is an example of a JSON payload for an entity:

{
"audited": true,
"read_only": false,
"importable": true,
"show_on_menu": true,
"schema": "dasec",
"datasource": "",
"object_name": "entity",
"object_label": "Entity",
"fields": [],
"list_as": [],
"relationships": []
}
FieldTypeDefault ValueRequiredDescription
lennumber0YesLength of the field (for strings, etc).
sizenumber0YesSize of the field (for numeric, etc).
precisionnumber0YesPrecision for decimal fields.
commentsstring""NoComments or notes about the field.
groupstring""NoGroup to which the field belongs.
helpstring""NoHelp text for the field.
labelstringYesLabel for display purposes.
namestringYesInternal name of the field.
schemastringpublicNoUnused, defaults to public, do not modify.
typestringintegerYesData type of the field.
regexstring""NoRegular expression for validation.
default_expstring""NoDefault value expression.
options_expstring""NoExpression to generate options.
auditedbooleantrueNoIndicates if changes to the field are audited.
importablebooleanfalseNoIndicates if the field can be imported.
reportablebooleanfalseNoIndicates if the field is reportable.
visiblebooleantrueNoDetermines if the field is visible in the UI.
auto_incrementbooleanfalseNoIf true, the field auto-increments.
default_valueanynullNoDefault value for the field.
editablebooleantrueNoIf true, the field is editable.
indexablebooleantrueNoIf true, the field is indexable.
inline_editbooleanfalseNoIf true, the field can be edited inline.
readonlybooleanfalseNoIf true, the field is read-only.
requiredbooleantrueNoIf true, the field is required.
searchablebooleantrueNoIf true, the field is searchable.
uniquebooleanfalseNoIf true, the field must be unique.
optionsArray<Option>[]NoList of options for select fields.

The following field types are supported:

TypeValue (key)Description
Date and timedatetimeDate and time value
DatedateDate value
TimetimeTime value
TexttextLong text
StringstringShort text or string
OptionoptionSelectable option
NumbernumberNumeric value
DecimaldecimalDecimal number
IntegerintegerInteger number
ArrayarrayArray of values
BooleanbooleanTrue/false value
FilefileFile upload
ImageimageImage upload
{
"len": 0,
"size": 0,
"precision": 0,
"comments": "",
"group": "",
"help": "",
"label": "Field",
"name": "field",
"schema": "public",
"type": "integer",
"regex": "",
"options": [],
"default_exp": "",
"options_exp": "",
"audited": true,
"importable": false,
"reportable": false,
"visible": true,
"auto_increment": false,
"default_value": null,
"editable": true,
"indexable": true,
"inline_edit": false,
"readonly": false,
"required": true,
"searchable": true,
"unique": true
}
FieldTypeDefault ValueRequiredDescription
relation_namestringYesInternal name of the relationship.
namestringYesSame as relation_name, for compatibility.
labelstringYesHuman-readable label for the relationship.
relationship_typestringYesType of relationship the entity has with another. (type)
typestringYesone-to-one, many-to-one, one-to-many, many-to-many.
l_entitystringYesLeft entity ID
l_keystringYesThe column in the left entity of the relationship.
r_entitystringYesRight entity ID
r_keystringYesKey in the right entity.
dependencystring""NoIf this relationship depends on a third entity, set.
dependency_relationstring""NoRelationship it depends on third entity, if any.
{
"relation_name": "RS_00000000-0000-0000-AAAA-0123456789AB.right_id_00000000-0000-0000-BBBB-0123456789AB.id",
"name": "RS_00000000-0000-0000-AAAA-0123456789AB.right_id_00000000-0000-0000-BBBB-0123456789AB.id",
"label": "menu_has_category_menu -> menu",
"relationship_type": "many-to-one",
"type": "many-to-one",
"l_entity": "00000000-0000-0000-AAAA-0123456789AB",
"l_key": "right_id",
"r_entity": "00000000-0000-0000-BBBB-0123456789AB",
"r_key": "id",
"dependency": "",
"dependency_relation": ""
}

Create a new entity. Stored to be manipulated in the Studio.

Endpoint:

POST /api/v1/entities?version=:version
<Entity>

Response Example:

{
"status": 201,
"error": false,
"message": "string",
"entityName": "string",
"data": [ { <Entity> } ]
}

Update an existing entity. Stored to be manipulated in the Studio.

Endpoint:

PUT /api/v1/entities/:entity?version=:version

Request Example:

{
"audited": true,
"importable": true,
"readOnly": false,
"showOnMenu": true,
"datasource": "",
"listAs": []
}

Response Example:

{
"status": 200,
"error": false,
"message": "string",
"entityName": "string",
"data": [ { <Entity> } ]
}

Delete an existing entity.

Endpoint:

DELETE /api/v1/entities/:entity?version=:version

Response Example:

{
"status": 200,
"error": false,
"message": "string",
"entityName": "string"
}

Returns the entity fields.

Endpoint:

GET /api/v1/entities/:entity/fields?page=:page&limit=:limit?&version=:version

Response Example:

{
"status": 200,
"error": false,
"message": "string",
"entityName": "string",
"data": [ { <Field> } ],
"pagination": { <Pagination> }
}

Add a field in the JSON entity field.

Endpoint:

POST /api/v1/entities/:entity/fields?version=:version
<Field>

Response Example:

{
"status": 201,
"error": false,
"message": "string",
"entityName": "string",
"data": [ { <Field> } ]
}

Updates a field in the JSON entity field.

Endpoint:

PUT /api/v1/entities/:entity/fields/:field?version=:version
<Field>

Response Example:

{
"status": 200,
"error": false,
"message": "string",
"entityName": "string",
"data": [ { <Field> } ]
}

Deletes a field in the JSON entity field.

Endpoint:

DELETE /api/v1/entities/:entity/fields/:field?version=:version

Response Example:

{
"status": 200,
"error": false,
"message": "string",
"entityName": "string"
}

Returns the entity relationships.

Endpoint:

GET /api/v1/entities/:entity/relationships?page=:page&limit=:limit&direct=:direct&version=:version

Response Example:

{
"status": 200,
"error": false,
"message": "string",
"entityName": "string",
"data": [ { <Relationship> } ],
"pagination": { <Pagination> }
}

Creates a relationship in the JSON entity file and its data in the database.

Endpoint:

POST /api/v1/entities/relationships?version=:version
<Relationship>

Response Example:

{
"status": 201,
"error": false,
"message": "string",
"entityName": "string",
"data": [ { <Relationship> } ]
}

Updates a relationship in the JSON entity file and its data in the database.

Endpoint:

PUT /api/v1/entities/:entity/relationships/:relationship?version=:version
<Relationship>

Response Example:

{
"status": 200,
"error": false,
"message": "string",
"entityName": "string",
"data": [ { <Relationship> } ],
"pagination": { <Pagination> }
}

Deletes a relationship in the JSON entity file and its data in the database.

Endpoint:

DELETE /api/v1/entities/:entity/relationships/:relationship?version=:version

Response Example:

{
"status": 200,
"error": false,
"message": "string",
"entityName": "string"
}

Get an entity attribute or settings.

Endpoint:

GET /api/v1/entities/:entity/:attribute

Response Code:

  • 200: OK