mysql@1.3.3
Functions
- execute(operations) ⇒
Operation
Execute a sequence of operations. Wraps
language-common/execute
, and prepends initial state for mysql.- insert(table, fields) ⇒
Operation
Insert a record
- upsert(table, fields) ⇒
Operation
Insert or Update a record if matched
- upsertMany(table, data) ⇒
Operation
Insert or update multiple records using ON DUPLICATE KEY
- query(options) ⇒
Operation
Execute a SQL statement
- sqlString(queryString) ⇒
Operation
Execute a SQL statement
execute(operations) ⇒ Operation
Execute a sequence of operations.
Wraps language-common/execute
, and prepends initial state for mysql.
Kind: global function
Param | Type | Description |
---|---|---|
operations | Operations | Operations to be performed. |
Example
execute(
create('foo'),
delete('bar')
)(state)
insert(table, fields) ⇒ Operation
Insert a record
Kind: global function
Param | Type | Description |
---|---|---|
table | string | The target table |
fields | object | A fields object |
Example
execute(
insert('table', fields(
field('name', dataValue('name'))
))
)(state)
upsert(table, fields) ⇒ Operation
Insert or Update a record if matched
Kind: global function
Param | Type | Description |
---|---|---|
table | string | The target table |
fields | object | A fields object |
Example
execute(
upsert('table', fields(
field('name', dataValue('name'))
))
)(state)
upsertMany(table, data) ⇒ Operation
Insert or update multiple records using ON DUPLICATE KEY
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
table | string | The target table |
data | array | An array of objects or a function that returns an array |
Example
upsertMany(
'users', // the DB table
[
{ name: 'one', email: 'one@openfn.org' },
{ name: 'two', email: 'two@openfn.org' },
]
)
query(options) ⇒ Operation
Execute a SQL statement
Kind: global function
Param | Type | Description |
---|---|---|
options | object | Payload data for the message |
Example
execute(
query({ sql: 'select * from users;' })
)(state)
sqlString(queryString) ⇒ Operation
Execute a SQL statement
Kind: global function
Param | Type | Description |
---|---|---|
queryString | String | A query string (or function which takes state and returns a string) |
Example
execute(
sqlString(state => "select * from items;")
)(state)