Types
Data types are the categories of data values that can be stored, processed, and retrieved by a programming language. Common data types include numbers (integers, floats, complex), characters (single characters, strings), booleans (true/false), dates, times, and null/undefined values. Additionally, derived data types include arrays (ordered collections) and objects (unordered collections of named values). Each data type has its own set of properties and operations that can be performed on it, such as comparison, arithmetic, and casting. Understanding data types is crucial for writing effective and efficient code that accurately processes and manipulates data.
Having a universal type system allows for each integration between various services across technology stacks, programming language, and system boundaries.
Standard Data Types
All the blocks in kis.ai, support standard data types and these form the foundation for strong type-safe way to integrate services.
Data Type | Description | Postgres | GraphQL | JSON |
---|---|---|---|---|
klid | kis.ai ulid, used as identity field for users, delegates, bots and agents | char(27) | ID | string |
ulid | ulid is better suited than guid as its lexicographically sortable | char(26) | ID | string |
byte | 8 bits of data, typical used for storing flag information | byte | Byte | integer |
bytes | array of bytes, useful for binary data | bytea | [Byte] | array(integers) |
int | 32-bit int | int | Int | integer |
bigint | 64-bit int | bigint | Int | integer |
double | double precision floating point number | float8 | Float | double |
boolean | boolean values, true or false | boolean | Boolean | boolean |
date | date | date | String | string |
datetime | timestamp without timezone, no timezone calculations performed | int | Int | string |
timestamp | timestamp with timezone information | timestamptz | String | string |
string | variable length characters, useful for storing text information. This is the default datatype | text | String | string |
object | an object with properties, typically used to store embeddables | jsonb | object | |
array(<type>) | array of values of other primitive data types or objects | jsonb | array | |
enum | native enum datatype | int | Int | string |
Custom Data Types
In some situations, new types need to be created. Data API allows creation of custom data types. Each custom data types will have encode and decode functions for encoding data before storing in database and decoding after reading from the database.
Here is an example where a binary data is encoded into base64 and being stored as text in the database.
Encoding and Decoding by Database
Encoding and Decoding by Application
Symbols
In more advanced use cases, some User-Defined Functions (UDFs) or functions provided by database extensions can be exposed to be used by developers. Symbols are added to datastore, to enable their usage in the database. Symbols are database specific, like types.
User-Defined Functions
Database specific User-Defined Functions can be added to a datastore. This are advanced features, and should be avoided as much as possible.