Transformer Pipeline Module API Reference (JavaScript)
7.0.2.308589
|
![]() |
The persistence module if loaded exposes some methods to pipelines to enable control of the persistence of data.
Functions | |
persist.query (var table, var query, var args, var row_cb, var ordering, var limit) | |
Query the Database for matching values. More... | |
persist.store (var table, var keys, var data) | |
Store a value in the persistence Database. More... | |
persist.remove (var table, var selector) | |
Remove a value in the persistence Database. More... | |
persist.get (var table, var selector, var row_cb, var ordering, var limit) | |
Retrieve a value from the persistence Database. More... | |
persist.get | ( | var | table, |
var | selector, | ||
var | row_cb, | ||
var | ordering, | ||
var | limit | ||
) |
Retrieve a value from the persistence Database.
table | table to be queried |
selector | table containing all the colums with their keys, e.g. { "firstname": "bob", "lastname": "bar" } |
row_cb | function to be called for every row returned by the query. The callback functions takes one argument containing a map with all the column-value pairs for a row. |
ordering | optional map of the form { "age": "ASC", "mark": "DESC" } where "ASC" and "DESC" are the only two allowed values |
limit | optional max number of rows to be returned |
-1 | on error. |
This function executes a query against a database table and returns the rows returned in the result set. The key-value pairs in selector
are built into a where clause where every key-value pair represents column/value combinations in the database table and are used in conjunction. A resulting SQL query for a selector { "a": "10", "b": "20" } would look like select * from table
where a = 10 and b = 20
Keys in the map passed to the callback are always uppercase for DMBS independence.
Example:
persist.query | ( | var | table, |
var | query, | ||
var | args, | ||
var | row_cb, | ||
var | ordering, | ||
var | limit | ||
) |
Query the Database for matching values.
table | table to be queried |
query | sql where clause in the format "a=? or b>?" or null for all rows |
args | array of arguments to be bound to the '?' characters in the query, in the form '[ arg1, arg2, arg3 ]; |
row_cb | function to be called for every row return by the query. The callback functions takes one argument containing a map with all the column-value pairs for a row. |
ordering | optional map of the form { "age": "ASC", "mark": "DESC" } where "ASC" and "DESC" are the only two allowed values |
limit | optional max number of rows to be returned |
This function executes a query against a database and calls row_cb for every row returned by the query. If this function is called with a query like "a=? and b<?" and an args list of ["foo", "20"] then the resulting sql query would look like: select * from table
where a="foo" and b<20
Keys in the map passed to the callback are always uppercase for DMBS independence.
Example:
persist.remove | ( | var | table, |
var | selector | ||
) |
Remove a value in the persistence Database.
table | table to delete rows from |
selector | dictionary of key-value pairs to restrict the rows to be deleted. |
-1 | on error. |
This function attempts to delete rows where all columns specified as keys in selector
match the values in selector
. A call to this function with a map like { "firstname": "bob", "lastname": "bar" } would result in a sql query similar to delete from table table
where firstname = bob and lastname = bar;
persist.store | ( | var | table, |
var | keys, | ||
var | data | ||
) |
Store a value in the persistence Database.
table | table update or insert should be executed against |
keys | dictionary containing key-value pairs to be used in the where clause for the update |
data | dictionary containing key-value pairs that should be put |
-1 | on error. |
This function attempts to update rows where all key-value pairs given in keys
match column/value pairs in the database. If this operation results in 0 affected rows, then a merged version of keys
and data
is inserted into the table. If keys and data share columns then the value of the data
map will be taken and the value of keys
is ignored.