mysql@2.0.5
- insert(table, fields)
- query(options)
- sqlString(queryString)
- upsert(table, fields)
- upsertMany(table, data)
This adaptor exports the following from common:
- alterState()
- arrayToString()
- combine()
- dataPath()
- dataValue()
- each()
- field()
- fields()
- fn()
- fnIf()
- http
- lastReferenceValue()
- merge()
- sourceValue()
Functions
insert
insert(table, fields) ⇒ Operation
Insert a record
Param | Type | Description |
---|---|---|
table | string | The target table |
fields | object | A fields object |
Example
execute(
insert('table', fields(
field('name', dataValue('name'))
))
)(state)
query
query(options) ⇒ Operation
Execute a SQL statement
Param | Type | Description |
---|---|---|
options | object | Payload data for the message |
Example
execute(
query({ sql: 'select * from users;' })
)(state)
sqlString
sqlString(queryString) ⇒ Operation
Execute a SQL statement
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)
upsert
upsert(table, fields) ⇒ Operation
Insert or Update a record if matched
Param | Type | Description |
---|---|---|
table | string | The target table |
fields | object | A fields object |
Example
execute(
upsert('table', fields(
field('name', dataValue('name'))
))
)(state)
upsertMany
upsertMany(table, data) ⇒ Operation
Insert or update multiple records using ON DUPLICATE KEY
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' },
]
)