MySQL
MySQL
The MySQL module is responsible for creating a connection and handling data of a MySQL database.
Methods
connection
Action responsible for creating a connection with the MySQL database.
const connection = await Database.MySQL.connection.v1_0_0({
host: '',
port: number,
user: '',
password: '',
localAddress?: '',
socketPath?: '',
timezone?: '',
connectTimeout?: number,
stringifyObjects?: boolean,
insecureAuth?: boolean,
typeCast?: boolean,
supportBigNumbers?: boolean,
bigNumberStrings?: boolean,
dateStrings?: boolean,
debug?: boolean,
trace?: boolean,
multipleStatements?: boolean,
flags?: '',
ssl?: '',
database?: '',
})
Required parameters
host: String - expects the host name of the database you are connecting to.port: Number - expects the number of the port you want to connect to.user: String - expects the MySQL user.password: String - expects the MySQL password.
Optional parameters
database: String - name of the database.localAddress: String - origin IP address to be used for the TCP connection.socketPath: String - path to a unix domain socket you want to connect to.timezone: Number - time zone configured on the MySQL server.connectTimeout: Number - milliseconds for the connection time limit with the MySQL server.stringifyObjects: Boolean - iftrue, objects are converted to string.insecureAuth: Boolean - iftrue, it allows connection with instances that request the old (insecure) authentication.typeCast: Boolean - iftrue, column values are converted into native JavaScript types.supportBigNumbers: Boolean - iftrue, it handles BIGINT and DECIMAL columns.bigNumberStrings: Boolean - iftrue, forces BIGINT and DECIMAL to be returned as String.dateStrings: Boolean - iftrue, forces date types to be returned as strings.debug: Boolean - iftrue, prints protocol details to stdout.trace: Boolean - iftrue, it generates Error stack traces.multipleStatements: Boolean - iftrue, it allows multiple MySQL statements per query.flags: String - flags to be inserted into or removed from the queries.ssl: String - object with SSL parameters or a string with the name of the SSL profile.
Return
This action has no return.
getDataValue
Action responsible for getting a given piece of data from a position of the response of an SQL command executed in a MySQL database.
const getDataValue = await Database.MySQL.getDataValue.v1_0_0({
column: '',
row: 1,
query: ''
})
Required parameters
column: String - name of the desired MySQL column.row: Number - position where the desired data is in the return of the query executed.
Optional parameters
query: String - ID of the MySQL connection created earlier by the connection action.
Return
The constant or variable created, such as the getDataValue of the example shown earlier, receives a value of the Object type. The object returned has the following property:
getDataValue.values: text - returns the data obtained from a MySQL query.
getReply
Action responsible for getting the response of an SQL command executed in a MySQL database. It can be used after a SELECT.
const getReply = await Database.MySQL.getReply.v1_0_0({
query: ''
})
Required parameters
This action has no required parameters.
Optional parameters
query: String - ID of the MySQL connection created earlier by the connection action.
Return
The constant or variable created, such as the getReply of the example shown earlier, receives a value of the Object type. The object returned has the following property:
getReply.values: array - returns the results of a SELECT executed in a MySQL query.
query
Action responsible for executing an SQL command in a MySQL database.
const query = await Database.MySQL.query.v1_0_0({
connection: connection,
query: '',
timeout: 1
})
Required parameters
connection: Return of the connection action - ID of the MySQL connection created earlier.query: String - query to be executed. Example:SELECT * FROM teste.teste.timeout: Number - waiting time in seconds for the execution of the action. Default:0.
Return
The constant or variable created, such as the query of the example shown earlier, receives a value of the Object type. The object returned has the following properties:
query.size: number - amount of data returned by the query.query.query: text - indicates whether the query was executed.query.response: array - results of the query.query.insertedId: number - ID of the record inserted.query.affectedRows: number - number of rows affected.query.changedRows: number - number of rows changed.
close
Action responsible for closing a connection with the MySQL database.
await Database.MySQL.close["v1_0_0"]({
connection: connection,
})
Required parameters
connection: Return of the connection action - expects the connection obtained through the connection action.
Optional parameters
This action has no optional parameters.
Return
This action has no return.
transactionBegin
Action responsible for starting a transaction in a MySQL connection.
await Database.MySQL.transactionBegin["v1_0_0"]({
connection: connection,
})
Required parameters
connection: Return of the connection action - expects the connection obtained through the connection action.
Optional parameters
This action has no optional parameters.
Return
This action has no return.
transactionCommit
Action responsible for committing a transaction started in a MySQL connection.
await Database.MySQL.transactionCommit["v1_0_0"]({
connection: connection,
})
Required parameters
connection: Return of the connection action - expects the connection obtained through the connection action.
Optional parameters
This action has no optional parameters.
Return
This action has no return.
transactionRollback
Action responsible for rolling back a transaction started in a MySQL connection.
await Database.MySQL.transactionRollback["v1_0_0"]({
connection: connection,
})
Required parameters
connection: Return of the connection action - expects the connection obtained through the connection action.
Optional parameters
This action has no optional parameters.
Return
This action has no return.