---
title: Storage
project: IoT Platform
version: 1.0
section: development
language: en
translation: missing
license: Total.js Enterprise
url: https://totaljs.es/docs/de/iot/1-0/development/storage/
updated: 2026-11-20T06:56:18.114Z
---

# Storage

> Keep your own data of a driver in database tables and read it in reports.

A driver can keep its own tables in the PostgreSQL database, for example every raw reading or the state of a parking lot. Declare the tables in `exports.storage`, and the platform creates them when you save the driver.

## Declare a table

```js
exports.storage = [{
	id: 'readings',
	name: 'Readings',
	columns: [
		{ id: 'sn', name: 'Serial number', type: 'string' },
		{ id: 'temperature', name: 'Temperature', type: 'number' }
	]
}];
```

The column types are `string`, `number`, `boolean`, `date` (date and time), `date2` (date only), `smallint` and `integer`. Every table also gets an `id` and a `dtcreated` column with the time of the insert.

When you change the columns and save the driver again, the platform adds, changes and removes the columns. Removing a table from `exports.storage`, or removing the driver, deletes the table and its data.

## Insert a row

```js
instance.storage.insert('readings', { sn: data.sn, temperature: temperature });
```

Only the declared columns are written. The `id` and `dtcreated` are filled in automatically.

## Read the data

The tables are in the `storage` schema. Their names start with `db`, followed by a code made from the id of the driver and the id of the table. List them with this query in a report preview:

```sql
SELECT table_name FROM information_schema.tables WHERE table_schema = 'storage'
```

Then read a table in a report:

```sql
SELECT sn, temperature, dtcreated FROM storage.db1yr6f1treadings ORDER BY dtcreated DESC
```

See [Keep every reading of a device in a report](../../recipes/keep-raw-readings/).
