Node.js MySQL Result Object – Examples

Node.js MySQL Result Object

When a MySQL Query is executed in Node.js, an object called Result Object is returned to the callback function. The Result Object contains result set or properties that provide information regarding the execution of a query in MySQL Server.

MySQL QueryResult Object
SELECT FROMResult Set containing Record
INSERT INTOObject containing Execution Status
UPDATEObject containing Execution Status
DELETE FROMObject containing Execution Status

We shall see how to access properties of records in a result set and how to access properties of execution status with the help of following examples.

 

Example – MySQL SELECT FROM Query – Accessing ResultSet

We can access the records in Result Set as an array and properties of a record using DOT (.) Operator.

Run the above program using node in Terminal

 

Example – MySQL INSERT INTO Query – Accessing properties of Node.js MySQL Result Object

We can access the properties of a Result Object using DOT (.) Operator.

Run the above program using node in Terminal

 

Example – MySQL UPDATE Query – Accessing properties of Node.js MySQL Result Object

We can access the properties of a Result Object using DOT (.) Operator.

Run the above program using node in Terminal

 

Example – MySQL DELETE FROM Query – Accessing properties of Node.js MySQL Result Object

We can access the properties of a Result Object using DOT (.) Operator.

Run the above program using node in Terminal

 

Conclusion :

In this Node.js Tutorial – Node.js MySQL – Record Object, we have learnt to access records of a result set and also went through examples to access properties of result object containing information about query execution.