Skip to main content

mysql@1.3.0

Adaptor

Adaptor.execute

Kind: static class of Adaptor

new exports.execute(operations)

Execute a sequence of operations. Wraps language-common/execute, and prepends initial state for mysql.

ParamTypeDescription
operationsOperationsOperations to be performed.

Example

execute(
create('foo'),
delete('bar')
)(state)

Adaptor.insert

Kind: static class of Adaptor

new exports.insert(table, fields)

Insert a record

ParamTypeDescription
tablestringThe target table
fieldsobjectA fields object

Example

execute(
insert('table', fields(
field('name', dataValue('name'))
))
)(state)

Adaptor.upsert

Kind: static class of Adaptor

new exports.upsert(table, fields)

Insert or Update a record if matched

ParamTypeDescription
tablestringThe target table
fieldsobjectA fields object

Example

execute(
upsert('table', fields(
field('name', dataValue('name'))
))
)(state)

Adaptor.upsertMany

Kind: static class of Adaptor
Access: public

new exports.upsertMany(table, data)

Insert or update multiple records using ON DUPLICATE KEY

ParamTypeDescription
tablestringThe target table
dataarrayAn 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' },
]
)

Adaptor.query

Kind: static class of Adaptor

new exports.query(options)

Execute a SQL statement

ParamTypeDescription
optionsobjectPayload data for the message

Example

execute(
query({ sql: 'select * from users;' })
)(state)

Adaptor.sqlString

Kind: static class of Adaptor

new exports.sqlString(queryString)

Execute a SQL statement

ParamTypeDescription
queryStringStringA query string (or function which takes state and returns a string)

Example

execute(
sqlString(state => "select * from items;")
)(state)