Types and Values

Overview

Platio supports several types to store values in a record. For instance, there are String type to store text, Number type to store a number as well as Attachment type to store an attachment such as an image and a video.

When you create a MiniApp on Platio Studio, you add a field to a Data Pocket and each field has its own type such as Text, Currency, Image and so on. As described in Platio API Programming Guide, a Column is created to store a value for the field when you create a field. A type of this Column is determined by the type of this field. For example, when you create a Text field, it creates a String Column. It creates a Number Column for a Currency field, an Attachment Column for an Image field, and so on.

Visit the Developer page in Data Viewer, or get the Application definition to see types of Columns.

A Value of each type has its own JSON representation. For example, String Value is represented like this.

{
  "type": "String",
  "value": "This is a string value."
}

An Attachment Value looks like this.

{
  "type": "Attachment",
  "id": "ac2lzz2afdvguze5znhselxd4oe",
  "name": "photo.jpeg",
  "contentType": "image/jpeg",
  "size": 1542161
}

When you get a record, you’ll see these values in each record. You need to construct valid Values when you create and update a Record.

To construct Values, create an object whose keys are Column IDs and values are Values for Columns like this.

{
  "values": {
    "c002c2c0": {
      "type": "String",
      "value": "Scott Tiger"
    },
    "cfe0266a": {
      "type": "Attachment",
      "id": "ac2lzz2afdvguze5znhselxd4oe",
      "contentType": "image/jpeg",
      "name": "image.jpeg",
      "size": 254179
    },
    "c915a0bc": {
      "type": "Number",
      "value": 28
    }
  }
}

If you don’t want to include a Value for a specific Column, just omit it from the object. For example, the Values below only contains a Value for a Column c002c2c0 and set nothing to the other Columns.

{
  "values": {
    "c002c2c0": {
      "type": "String",
      "value": "Scott Tiger"
    }
  }
}

Do not set null to a Value itself or properties in each Value. Using these Values will cause an error.

{
  "values": {
    "c002c2c0": {
      "type": "String",
      "value": null
    },
    "c915a0bc": null
  }
}

Simple Types

String

A String Value represents an arbitrary text.

{
  "type": "String",
  "value": "String value"
}

Sort

When you sort records by a String Column, they’re sorted by a value itself in case-sensitive manner.

Type in Platio Expressions

String. The default value is an empty string.

Number

A Number Value represents any finite number, float or integer.

{
  "type": "Number",
  "value": 123456
}

Sort

When you sort records by a Number Column, they’re sorted by a value itself.

Type in Platio Expressions

Number. The default value is 0.

Boolean

A Boolean value represents a boolean.

{
  "type": "Boolean",
  "value": true
}

Sort

When you sort records by a Boolean Column, they’re sorted by a value itself. false is treated smaller than true.

Type in Platio Expressions

Boolean. The default value is false.

DateTime

A DateTime value represents a date and time. It’s formatted in the ISO 8601 format YYYY-MM-DD'T'hh:mm:ss.sssZ in JSON.

{
  "type": "DateTime",
  "value": "2016-05-18T11:16:34.348Z"
}

You can specify POSIX time when you create or update a record.

{
  "type": "DateTime",
  "value": 1510625619
}

Note that it returns the value in the ISO 8601 format when you retrieve this record even if you’ve created a record using POSIX time format.

Sort

When you sort records by a DateTime Column, they’re sorted by a value itself.

Type in Platio Expressions

Date. The default value is undefined.

Date

A Date value represents a date. It’s formatted in the ISO 8601 format YYYY-MM-DD in JSON.

{
  "type": "Date",
  "value": "2016-05-15"
}

Sort

When you sort records by a Date Column, they’re sorted by a value itself.

Type in Platio Expressions

String. The default value is undefined.

Time

A Time value represents time. It’s formatted in the ISO 8601 format hh:mm:ss in JSON.

{
  "type": "Time",
  "value": "11:16:34"
}

Sort

When you sort records by a Time Column, they’re sorted by a value itself.

Type in Platio Expressions

String. The default value is undefined.

Location

A Location value represents a location, with required latitude and longitude and an optional altitude. All values are float.

{
  "type": "Location",
  "latitude": 35.685,
  "longitude": 139.7513889,
}
{
  "type": "Location",
  "latitude": 35.685,
  "longitude": 139.7513889,
  "altitude": 54.3
}

Sort

You cannot sort records by a Location Column.

Type in Platio Expressions

Object with latitude, longitude, altitude properties. The default value is undefined.

User

A User value represents a User, with its id and its name.

{
  "type": "User",
  "id": "uf598c3f",
  "name": "user1"
}

Sort

When you sort records by a User Column, they’re sorted by their names in case-sensitive manner.

Type in Platio Expressions

String representing a name. The default value is undefined.

Attachment Types

Attachment

An Attachment value represents an attachment, composed by its ID, name, content type and size.

When you create an Attachment Value, create an Attachment by uploading a file before and use ID, name, contentType and size returned.

{
  "type": "Attachment",
  "id": "ac2lzz2afdvguze5znhselxd4oe",
  "name": "photo.jpeg",
  "contentType": "image/jpeg",
  "size": 1542161
}

Sort

When you sort records by an Attachment Column, they’re sorted by their names in case-sensitive manner.

Type in Platio Expressions

String representing a name. The default value is undefined.

Compound Types

Compound types are types that contain multiple Values in them.

Object

An Object value is a mapping of keys and values. Simple types can be a member of an Object value.

For each Column of Object type, there is scheme which defines what keys it can have and what’s the type of each key. Visit the Developer page in Data Viewer to see scheme of Object Columns.

{
  "type": "Object",
  "value": {
    "systolic": {
      "type": "Number",
      "value": 121
    },
    "diastolic": {
      "type": "Number",
      "value": 53
    },
    "pulseRate": {
      "type": "Number",
      "value": 66
    }
  }
}

Scheme

You can also get scheme of a Column by getting an Application definition. It contains a Column definition with its scheme.

{
  "id": "cd234a8a",
  "name": "Blood Pressure",
  "type": "Object",
  "scheme": {
    "keys": [
      {
        "name": "systolic",
        "type": "Number"
      },
      {
        "name": "diastolic",
        "type": "Number"
      },
      {
        "name": "pulseRate",
        "type": "Number"
      }
    ]
  },
  "unique": false,
  "sortable": false,
  "searchable": false
}

Sort

You cannot sort records by an Object Column.

Type in Platio Expressions

Object. All values in an object will be converted too. The default value is undefined.

Array

An Array value is an array of Values. Each Value in an array must be of the same type. Simple types and Object can be a member of an array.

For each Column of Array type, there is scheme which defines what type of values it can have. Visit the Developer page in Data Viewer to see scheme of Array Columns.

{
  "type": "Array",
  "value": [
    {
      "type": "Number",
      "value": 10.1
    },
    {
      "type": "Number",
      "value": 14.34
    }
  ]
}
{
  "type": "Array",
  "value": [
    {
      "type": "Object",
      "value": {
        "timestamp": {
          "type": "DateTime",
          "value": "2017-05-03T11:32:65.312Z"
        },
        "temperature": {
          "type": "Number",
          "value": 21.3
        }
      }
    },
    {
      "type": "Object",
      "value": {
        "timestamp": {
          "type": "DateTime",
          "value": "2017-05-04T11:32:65.312Z"
        },
        "temperature": {
          "type": "Number",
          "value": 18.8
        }
      }
    }
  ]
}

Scheme

You can also get scheme of a Column by getting an Application definition. It contains a Column definition with its scheme.

When an Array value contains values of a simple type, it’ll be like the following.

{
  "id": "cd234a8a",
  "name": "Values",
  "type": "Array",
  "scheme": {
    "element": {
      "type": "Number"
    }
  },
  "unique": false,
  "sortable": false,
  "searchable": false
}

When an Array value contains values of Object, its scheme also contains scheme of the Object type.

{
  "id": "cd234a8a",
  "name": "Values",
  "type": "Array",
  "scheme": {
    "element": {
      "type": "Object",
      "scheme": {
        "keys": [
          {
            "name": "timestamp",
            "type": "DateTime"
          },
          {
            "name": "temperature",
            "type": "Number"
          }
        ]
      }
    }
  },
  "unique": false,
  "sortable": false,
  "searchable": false
}

Sort

You cannot sort records by an Array Column.

Type in Platio Expressions

Array. All values in an array will be converted too. The default value is undefined.

Reference Types

Reference types are used to represent a Value that refers a Record in a Collection in the same Application.

ReferenceString

A ReferenceString value represents a reference to a Record and a String Value in the Record.

For each Column of ReferenceString type, there is scheme which defines which Collection and Column it refers to. Visit the Developer page in Data Viewer to see scheme of ReferenceString Columns.

First, a ReferenceString value has an id of a Collection and a Record, and a hash of a Record. These properties identify a Record that the Value refers. Then, it also contains an id of a Column and Value. These properties identify a Value in the referred Record.

{
  "type": "ReferenceString",
  "collectionId": "t5957d3a",
  "columnId": "c89c762f",
  "recordId": "refo5otf6fbb2lhgnwvhbc7jg5i",
  "recordHash": "f82b820234d79d99082318996ecc1c95cace3753",
  "value": {
    "type": "String",
    "value": "String value"
  }
}

A Value can be omitted when the referred Record doesn’t have a Value for this Column.

{
  "type": "ReferenceString",
  "collectionId": "t5957d3a",
  "columnId": "c89c762f",
  "recordId": "refo5otf6fbb2lhgnwvhbc7jg5i",
  "recordHash": "f82b820234d79d99082318996ecc1c95cace3753"
}

You can omit value and recordHash, and specify only type, collectionId, columnId, recordId when you set a Value. The server will complement value and recordHash.

Scheme

You can also find which Collection and Column it refers to by getting an Application definition. It contains a Column definition with its scheme.

{
  "id": "cd234a8a",
  "name": "Author",
  "type": "ReferenceString",
  "scheme": {
    "collectionId": "t5957d3a",
    "columnId": "c89c762f"
  },
  "unique": false,
  "sortable": true,
  "searchable": false
}

Sort

When you sort records by a ReferenceString Column, they’re sorted by their referring value as described in String type.

Type in Platio Expressions

String. The default value is an empty string.

ReferenceNumber

For each Column of ReferenceNumber type, there is scheme which defines which Collection and Column it refers to. Visit the Developer page in Data Viewer to see scheme of ReferenceNumber Columns.

A ReferenceNumber value represents a reference to a Record and a Number Value in the Record.

First, a ReferenceNumber value has an id of a Collection and a Record, and a hash of a Record. These properties identify a Record that the Value refers. Then, it also contains an id of a Column and Value. These properties identify a Value in the referred Record.

{
  "type": "ReferenceNumber",
  "collectionId": "t915a0bc",
  "columnId": "c002c2c0",
  "recordId": "ri5f3cykexfbkzk7ohzqm2oocni",
  "recordHash": "8b96a445815ca366aac07c70c722c9fdaa5bc932",
  "value": {
    "type": "Number",
    "value": 1234.56
  }
}

A Value can be omitted when the referred Record doesn’t have a Value for this Column.

{
  "type": "ReferenceNumber",
  "collectionId": "t915a0bc",
  "columnId": "c915a0bc",
  "recordId": "ri5f3cykexfbkzk7ohzqm2oocni",
  "recordHash": "8b96a445815ca366aac07c70c722c9fdaa5bc932"
}

You can omit value and recordHash, and specify only type, collectionId, columnId, recordId when you set a Value. The server will complement value and recordHash.

Scheme

You can also find which Collection and Column it refers to by getting an Application definition. It contains a Column definition with its scheme.

{
  "id": "cd234a8a",
  "name": "Author ID",
  "type": "ReferenceNumber",
  "scheme": {
    "collectionId": "t915a0bc",
    "columnId": "c915a0bc"
  },
  "unique": false,
  "sortable": true,
  "searchable": false
}

Sort

When you sort records by a ReferenceNumber Column, they’re sorted by their referring value as described in Number type.

Type in Platio Expressions

Number. The default value is 0.

ReferenceUser

A ReferenceUser value represents a reference to a Record and a User Value in the Record.

For each Column of ReferenceUser type, there is scheme which defines which Collection and Column it refers to. Visit the Developer page in Data Viewer to see scheme of ReferenceUser Columns.

First, a ReferenceUser value has an id of a Collection and a Record, and a hash of a Record. These properties identify a Record that the Value refers. Then, it also contains an id of a Column and Value. These properties identify a Value in the referred Record.

{
  "type": "ReferenceUser",
  "collectionId": "td5949fa",
  "columnId": "c79bc617",
  "recordId": "rvwoel2tefbd6zgx6qxqeogl4ey",
  "recordHash": "2fbd3fb6a9b6a76e9686dbcef38ec9b08b5f6787",
  "value": {
    "type": "User",
    "id": "uf598c3f",
    "name": "user1"
  }
}

A Value can be omitted when the referred Record doesn’t have a Value for this Column.

{
  "type": "ReferenceUser",
  "collectionId": "td5949fa",
  "columnId": "c79bc617",
  "recordId": "refo5otf6fbb2lhgnwvhbc7jg5i",
  "recordHash": "2fbd3fb6a9b6a76e9686dbcef38ec9b08b5f6787"
}

You can omit value and recordHash, and specify only type, collectionId, columnId, recordId when you set a Value. The server will complement value and recordHash.

Scheme

You can also find which Collection and Column it refers to by getting an Application definition. It contains a Column definition with its scheme.

{
  "id": "cd234a8a",
  "name": "Author",
  "type": "ReferenceUser",
  "scheme": {
    "collectionId": "td5949fa",
    "columnId": "c79bc617"
  },
  "unique": false,
  "sortable": true,
  "searchable": false
}

Sort

When you sort records by a ReferenceUser Column, they’re sorted by their referring value as described in User type.

Type in Platio Expressions

String representing a name. The default value is undefined.