Collections

Introduction

The ClearBlade IoT platform allows for storing different types of data in your IoT solution through Collections. Each collection is available for users and devices to access via Console, Portals, APIs and SDKs.

Within the context of the ClearBlade IoT Platform, a Collection is synonymous with a Database, and will be used extensively across the documentation.

To get a holistic view of collections, we categorize them into following sections:

For the collection management tutorial, click here

Purpose

ClearBlade Collections provide a single interface for interacting with numerous types of databases.

Queries

See ClearBlade Platform SDK for Collection API

Data Model Queries

Data Model allows developers to run raw SQL queries on platform and edge instead of using the existing ClearBlade query model. These SQL queries can run against collections, user and device tables. Developers should use the data model when running operations such as JOIN and other operations not supported by the ClearBlade Query Model.

See ClearBlade Native Libraries for the API

Collection Types

Cloud

ClearBlade provides a default cloud collection, which is backed by a Postgresql instance. These collections are able to be completely manipulated by the platform in terms of their schema, and the data put into them.

Connection

The Connection type allows the platform developer to integrate existing databases with their IoT Platform application.

  • MySQL
  • PostgreSQL
  • MongoDB
  • Oracle
  • DB2_Linux
  • DB2_zOS
  • DB2_System_i
  • Microsoft_SQL_Server
  • Cassandra
  • CouchDB

To request integrations, please create a ticket at Support

The following is required to configure a Connection:

Field Description Example
Database Type DB Application Type MySQL
IP Address URL of database mydb.databases.com
Port port number on which the application is running 5432
Database Name Name of Database dbname
Connection Name string example
Table Name string sensor_data
Username string admin
Password string zrHcnzpBenHSOIq0uK/og8R

Column Types

Type Description
string Series of characters. Example: “Column 1”
integer (int) Positive or negative whole number
boolean (bool) True/False
timestamp 03/29/21 22:15:07
float Numbers with decimals
bigint Large whole numbers
double Large numbers with decimals
jsonb See below
Binary Large Object (blob) A collection of binary data stored as a single entity
Universally Unique Identifier (uuid) A 128-bit unique identification value. Example: bc37d0c0-fcf2-11d9-8cd6-0800200c9a66

jsonb

jsonb enables users to store json values in the database tables and query based on keys (for objects) or indexes (for arrays). Send stringified data when creating and updating all tables on a jsonb column.

For list of operators and functions click here

Index/Unique Index

Collection columns can be indexed to speed up certain database operations. Unique indexing allows for unique values to be used. The async library for indexing can be found under the ‘Collection’ section here. To configure indexing, go to ‘Edit column’ in a collection and mark the box of the type of indexing under the column(s) of your choice.

FAQ

  • How do I format the timestamp column in javascript to insert it into a collection? > User can create a timestamp variable using: var curr_timestamp = new Date(); and can insert it into the collection.