Spanish Total.js
English
Documentation For AI agents
Contents

Databases

Components that read and write data in databases.

.md GitHub
On this page

Components that read and write data in databases. This page holds the catalogue group Databases.

Each entry lists the inputs and outputs of the component, its main settings and the text of its readme. To add a component to a FlowStream, see Download components.

API

component

influxdb.html · version 1

Writes data to InfluxDB or runs a Flux query.
ParameterTypeDescription
url? String Server url.
token? String Token.
org? String Organization.
bucket? String Bucket.
api? String Action. One of: write (Write data), query (Execute a Flux query).
fields? String Fields.
tags? String Tags.

Inputs: input (Input).

Outputs: output (Output).

Flow installs the npm package @influxdata/influxdb-client when you add the component.

Input

Expected data for "Write data":

{
    measurement: '<measurement-name>',
    fields: {
        fieldname: <fieldvalue>,
    },
    tags: {
        tagname: '<tagvalue>'
    }
}

Expected data for "Execute a Flux query":

{
    query: 'from(bucket: "Some Bucket") |> range(start: -1h)'
}
component

localstorage.html · version 1

Stores data for a short time and reads it back.
ParameterTypeDescription
savekey? String Save key. Default: id
readkey? String Read key. Default: id
path? String Where to save data?
remove? Boolean Remove the item after reading. Default: true
expire? String Expiration. Default: 1 hour

Inputs: save (Save), read (Read).

Outputs: output (Output), error (Error).

A small and simple persistent storage component is provided by this component. Data can be stored for a short period of time and read when needed.

component

mongodb-insert.html · version 1

Inserts documents into MongoDB.
ParameterTypeDescription
name? String Connection name.
connection? String Connection string (without the database name).

Inputs: input (Input).

Outputs: output (Output).

Flow installs the npm package mongodb@4.0.0 when you add the component.

Input

Example

{
    database: 'database-name',
    collection: 'collection-name',
    data: { ... },  // data to insert, object for `insertOne` and an array of objects for `insertMany`
    options: { ... }// insert options as passed to `insertOne(data, options)` or `insertMany(data, options)`
}
component

mongodb-query.html · version 2

Runs queries on MongoDB.
ParameterTypeDescription
fn? String Query editor. Default: return query.find();
name? String Connection name.
connection? String Connection string (without the database name).

Inputs: input (Input).

Outputs: output (Output).

Flow installs the npm packages mongodb@4.0.0, mquery when you add the component.

Uses mquery under the hood. Here is the documentation

Input

Example

{
    database: 'database-name',
    collection: 'collection-name',
    data: <any> // this prop will be passed into the query function
}

Query editor

// query; mquery instance
// data; data from the incomming object

return query.find(); // return all documents

Important

In the .select() you cannot use inclusion and exclusion together.

This is invalid: .select('firstname -lastname')

Valid exclusion: .select('-lastname') or .select('-email -lastname') etc.

Valid inclusion: .select('name email') or .select('email lastname') etc.

component

mysql.html · version 2

Runs SQL queries on a MySQL database.
ParameterTypeDescription
connection? String Connection string.

Inputs: input (Input).

Outputs: output (Output).

Flow installs the npm package mysql2 when you add the component.

Input

Expected data:

{
    query: 'SELECT * FROM tblname;'
}
component

nosql.html · version 1

Inserts, reads, queries, updates and removes documents in the Total.js NoSQL database.
ParameterTypeDescription
collection? String DB collection(table) name.
method? String Method. One of: insert (Insert), update (Update), read (Read), query (Query), remove (Remove).
addid? String Add unique ID to id property of data before insert.
upsert? String Insert document if it doesn't exist.
upsertid? String Add unique ID to id property of data before insert (only if it doesn't exist).

Inputs: input (Input).

Outputs: output (Output).

Outputs

  • response from nosql engine

Settings

  • collection: (optional) if not set, incomming data object must have a 'collection' property set
  • method: (optional) if not set, incomming data object must have a 'method' property set

Input

{
    collection: 'users', // optional, will override settings value
    method: 'query', // insert|read|query|update|remove - optional, will override settings value
    // for insert, update
    data: { ... },
    // for query, read, update, remove
    filter: [
        ['where', 'sensor', 'temp'], // builder.where('sensor', 'temp');
        ['limit', 2]                 // builder.limit(2);
    ],
    upsert: true // only for update, if set then document will be inserted if it doesn't exist
    addid: true  // only for insert and update, if set then id prop will be automaticaly generated (for update only when upsert is also set)
}

Insert

  • inserts recieved data
  • expects data to be an Object
  • returns error, success, id

Read

  • returns first document found
  • requires filter
  • returns error, response

Update

  • updates document(s)
  • expects data to be an Object with all the props to be updated
  • requires filter
  • returns error, response
  • if response is 0 then update failed

Remove

  • removes document
  • requires filter
  • returns error, response
  • if response is 0 then remove failed

Query

  • returns all documents found
  • requires filter
  • returns error, response
component

postgresql.html · version 2

Runs SQL queries on a PostgreSQL database.
ParameterTypeDescription
connection? String Connection string.

Inputs: input (Input).

Outputs: output (Output).

Flow installs the npm package pg when you add the component.

PostgreSQL

Input

Expected data:

{
    query: 'SELECT * FROM tblname;'
}

Output:

{
    command: 'INSERT', // SELECT, etc.
    rows: [], //
    rowCount: 1
}
component

sqlite3.html · version 2

Runs queries on an SQLite3 database.
ParameterTypeDescription
filename? String Filename (optional).

Inputs: input (Input).

Outputs: output (Output), error (Error).

Flow installs the npm package better-sqlite3 when you add the component.

SQLite3 Documentation

{
    // query
    prepare: 'INSERT INTO cats (name, age) VALUES (?, ?)',

    // function name: run, get, all, exec
    fn: 'run',

    // data, optional
    data: ['Joey', 2] // string/number or array

}

Functions:

Made in Europe