Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 1.8 KB

mysql.md

File metadata and controls

53 lines (41 loc) · 1.8 KB

mysql

Registers the contexts and methods of the module mySQL in microTasks.

mysql~context

Context item list registered in microTasks.

Name Type Default Description
mysql.connection.database string Connection data base name
mysql.connection.debug boolean false Connection debug mode
mysql.connection.host string Connection host
mysql.connection.password string Connection password
mysql.connection.port number 3306 Connection port
mysql.connection.user string Connection user

mysql~mysql.query(data)

Executes a mysql query and returns the response.

Name Type Default Description
data object {} query configuration
data.query string mySQL query
[data.connection] object {} Connection configuration. This object extends from context.mysql.connection
[data.handler] string "rows" Response handler, it can be column (array of values), field (value), row (object) or rows (array of objects)

Example

microTasks.taskRun([{
  method: 'mysql.query',
  params: {
    connection: {
      host: '127.0.0.1',
      user: 'db_user',
      password: 'db_pass'
    },
    query: 'SELECT email FROM db_name.users WHERE id=123 LIMIT 1',
    handler: 'field' // returns user email as a value
  }
}])