Item schemas
Schema structure
An LD Item Schema is a JSON object containing key value pairs that describe each field.
- category (required)
- This acts as a descriptive grouping of items by category. For example, “org” category refers to all item types that make up an org. The first letter of the category name MUST be lowercase. Behaviour of the system with uppercase typenames is undefined.
- type (required)
- Type of an item. The first letter of the type name MUST be uppercase. Behaviour of the system with lowercase typenames is undefined.
- permissionType
- Specifies how an item is permissioned. All - means all users get all items. Relationship - means only users related to this item get the item. None - means no user gets this item.
- priority
- 0-9. Specifies the order in which the items are processed by the system. Items with priority 0 are processed first, 9 are processed last.
- historyDaysToRetain
- How many days of item history to retain. Default is 30 days. Set to -1 to retain history indefinitely
- expireAfterDays
- Default is 0. Number of days beyond which this item is purged.
- auditLog
- Default is false. Set to true to track AuditLog of changes to this item type.
- report
- Default is false. Set to true to consider this a “report” item (see below)
- view
- Default is false. If set to true this item is backed by a view.
- materialized
- Set to true in conjunction with “view=true” if this view item is backed by a materialized view.
- viewName
- Name of the view this view item is backed by.
- viewStatement
- clientViewStatement
- viewMaintenanceTask
- viewDependantTypes
- fields
- JSON object defining each individual field that belongs to the item. See next section.
Fields
Each field can have the following properties. Properties in bold are REQUIRED. All other properties are OPTIONAL.
- primary
- When set to true this field makes up the primary key of this item. If no fields. This field SHOULD be defined, but if it isn’t the server will try to choose appropriate primary keys.
- name
- Name of this field
- dataType
- Type of this field, see section on Data Types below. “string” is the default.
- dimensionType
- Specifies the name of the dirmension if the dataType is “dimension”. If the dataType is dimension, this key is REQUIRED.
- searchIndexType
- searchIndexName
- Specifies which search index this field belongs to. By default searchIndexName=name. However, several fields can be combined into a single search index. For example, descriptionLine1, descriptionLine2 can be combined into a single index for better search experience.
- searhIndexReferenceType
- defaultValue
- Default value for this field. DefaultValues are applied each time the item is processed. If a field is not set, the default value is used from the schema.
- listElementType
- Type of elements within a list, if a field is of type ‘list’
- cloneAction
- A field that indicates what action should be taken when the item is cloned or copied. Valid values: “generate” - populates field with a UUID, “copy” - copies the value from the original item. An empty cloneAction results in the field being populated with whatever defaultValue is specified.
- comment
- A comment with a description of this field. This is used by neither server nor client.
- expireAfter
- boolean value. Set to true on a date field to automatically expire items after that date value. Only a single field can be marked.
- blockType
- The type of the schema defining the block. For example “Phone”. Category is not specified, all blocks are assumed to belong to category “block.”
Field Data Types
Data type | Java Type | ObjectiveC Type | SQL Type |
---|---|---|---|
int | int | NSNumber wrapping value.intValue | INTEGER |
decimal | double | NSDecimalNumber | FLOAT |
boolean | boolean | NSNumber wrapping value.boolValue | BOOLEAN |
date | java.util.Date | NSDate | TIMESTAMP without timezone |
string,name,phone,email,url,refnum | String | NSString | citext |
list | JsonArray | Either NSArray or NSDictionary of values depending on the JSON in the field’s value | Varies, Depending on ListElementType |
dimension | String | NSString | VARCHAR |
block | JsonObject | Varies, Depending on Block schema |
Item header.id generation
Item id is an SHA1 hash of item community+item category+item type+(values of primary fields in alphabetical order by field name).
Example Schema
Minimal schema:
{
"category": "entity",
"type": "Person",
"fields": [
{
"name": "firstName",
"dataType": "string"
},
{
"name": "lastName",
"dataType": "string"
}
]
}