Database
Componenti che leggono e scrivono dati nei database.
In questa pagina
Componenti che leggono e scrivono dati nei database. Questa pagina contiene il gruppo del catalogo Databases.
Ogni voce elenca gli ingressi e le uscite del componente, le sue impostazioni principali e il testo del suo readme. Per aggiungere un componente a un FlowStream, consulta Scaricare i componenti.
API
component
influxdb.html · version 1
Scrive dati in InfluxDB o esegue una query Flux.
influxdb.html · version 1| Parametro | Tipo | Descrizione |
|---|---|---|
url? |
String |
URL del server. |
token? |
String |
Token. |
org? |
String |
Organizzazione. |
bucket? |
String |
Bucket. |
api? |
String |
Azione. Una tra: write (Write data), query (Execute a Flux query). |
fields? |
String |
Campi. |
tags? |
String |
Tag. |
Ingressi: input (Input).
Uscite: output (Output).
Flow installa il pacchetto npm @influxdata/influxdb-client quando aggiungi il componente.
Ingresso
Dati attesi per "Write data":
{
measurement: '<measurement-name>',
fields: {
fieldname: <fieldvalue>,
},
tags: {
tagname: '<tagvalue>'
}
}Dati attesi per "Execute a Flux query":
{
query: 'from(bucket: "Some Bucket") |> range(start: -1h)'
}
component
localstorage.html · version 1
Conserva dati per poco tempo e li rilegge.
localstorage.html · version 1| Parametro | Tipo | Descrizione |
|---|---|---|
savekey? |
String |
Chiave di salvataggio. Predefinito: id |
readkey? |
String |
Chiave di lettura. Predefinito: id |
path? |
String |
Dove salvare i dati? |
remove? |
Boolean |
Rimuovi l'elemento dopo la lettura. Predefinito: true |
expire? |
String |
Scadenza. Predefinito: 1 hour |
Ingressi: save (Save), read (Read).
Uscite: output (Output), error (Error).
Questo componente offre un piccolo e semplice archivio persistente. Puoi salvare i dati per un breve periodo e leggerli quando ti servono.
component
mongodb-insert.html · version 1
Inserisce documenti in MongoDB.
mongodb-insert.html · version 1| Parametro | Tipo | Descrizione |
|---|---|---|
name? |
String |
Nome della connessione. |
connection? |
String |
Stringa di connessione (senza il nome del database). |
Ingressi: input (Input).
Uscite: output (Output).
Flow installa il pacchetto npm mongodb@4.0.0 quando aggiungi il componente.
Ingresso
Esempio
{
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
Esegue query su MongoDB.
mongodb-query.html · version 2| Parametro | Tipo | Descrizione |
|---|---|---|
fn? |
String |
Editor della query. Predefinito: return query.find(); |
name? |
String |
Nome della connessione. |
connection? |
String |
Stringa di connessione (senza il nome del database). |
Ingressi: input (Input).
Uscite: output (Output).
Flow installa i pacchetti npm mongodb@4.0.0, mquery quando aggiungi il componente.
Dietro le quinte usa mquery. Ecco la documentazione
Ingresso
Esempio
{
database: 'database-name',
collection: 'collection-name',
data: <any> // this prop will be passed into the query function
}Editor della query
// query; mquery instance
// data; data from the incomming object
return query.find(); // return all documentsImportante
In .select() non puoi usare inclusione ed esclusione insieme.
Questo non è valido: .select('firstname -lastname')
Esclusione valida: .select('-lastname') o .select('-email -lastname') ecc.
Inclusione valida: .select('name email') o .select('email lastname') ecc.
component
mysql.html · version 2
Esegue query SQL su un database MySQL.
mysql.html · version 2| Parametro | Tipo | Descrizione |
|---|---|---|
connection? |
String |
Stringa di connessione. |
Ingressi: input (Input).
Uscite: output (Output).
Flow installa il pacchetto npm mysql2 quando aggiungi il componente.
Ingresso
Dati attesi:
{
query: 'SELECT * FROM tblname;'
}
component
nosql.html · version 1
Inserisce, legge, interroga, aggiorna e rimuove documenti nel database NoSQL di Total.js.
nosql.html · version 1| Parametro | Tipo | Descrizione |
|---|---|---|
collection? |
String |
Nome della collezione (tabella) del DB. |
method? |
String |
Metodo. Uno tra: insert (Insert), update (Update), read (Read), query (Query), remove (Remove). |
addid? |
String |
Aggiungi un ID univoco alla proprietà id dei dati prima dell'inserimento. |
upsert? |
String |
Inserisci il documento se non esiste. |
upsertid? |
String |
Aggiungi un ID univoco alla proprietà id dei dati prima dell'inserimento (solo se non esiste). |
Ingressi: input (Input).
Uscite: output (Output).
Uscite
- risposta del motore NoSQL
Impostazioni
- collection: (facoltativo) se non è impostato, l'oggetto dei dati in arrivo deve avere la proprietà 'collection'
- method: (facoltativo) se non è impostato, l'oggetto dei dati in arrivo deve avere la proprietà 'method'
Ingresso
{
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
- inserisce i dati ricevuti
- si aspetta che i dati siano un Object
- restituisce error, success, id
Read
- restituisce il primo documento trovato
- richiede
filter - restituisce error, response
Update
- aggiorna uno o più documenti
- si aspetta che i dati siano un Object con tutte le proprietà da aggiornare
- richiede
filter - restituisce error, response
- se response è 0, l'aggiornamento non è riuscito
Remove
- rimuove il documento
- richiede
filter - restituisce error, response
- se response è 0, la rimozione non è riuscita
Query
- restituisce tutti i documenti trovati
- richiede
filter - restituisce error, response
component
postgresql.html · version 2
Esegue query SQL su un database PostgreSQL.
postgresql.html · version 2| Parametro | Tipo | Descrizione |
|---|---|---|
connection? |
String |
Stringa di connessione. |
Ingressi: input (Input).
Uscite: output (Output).
Flow installa il pacchetto npm pg quando aggiungi il componente.
PostgreSQL
Ingresso
Dati attesi:
{
query: 'SELECT * FROM tblname;'
}Uscita:
{
command: 'INSERT', // SELECT, etc.
rows: [], //
rowCount: 1
}
component
sqlite3.html · version 2
Esegue query su un database SQLite3.
sqlite3.html · version 2| Parametro | Tipo | Descrizione |
|---|---|---|
filename? |
String |
Nome del file (facoltativo). |
Ingressi: input (Input).
Uscite: output (Output), error (Error).
Flow installa il pacchetto npm better-sqlite3 quando aggiungi il componente.
SQLite3 Documentazione
{
// 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
}Funzioni: