Closed lakshmipriyamukundan closed 7 years ago
I am new to mysql. My previous work was in postgres. To do my project in node , I had used a library 'pg-promise'. There I could found options like 'task' to do series operations.
For an example, Operations:
These are series operations actually, how do I implement this with promise in promise-mysql?
Can you please explain it with some example?
Assuming the primary key is an autoincrementing integer:
var mysql = require('promise-mysql');
var connection;
mysql.createConnection({
host: 'localhost',
user: 'user',
password: 'password',
database: 'database'
}).then(function(conn){
connection = conn;
return connection.query('insert into Employee...');
}).then(function(results){
var id = results.insertId;
return connection.query('insert into EmployeeAddress...');
});
Thanks for the answer. :star:
The interesting part is that two inserts like this must be executed inside a transaction, in order to keep the data integrity. Perhaps this is what the author meant to ask about, when referencing to tasks/transactions support that pg-promise does :wink:
I'm not here to teach people how to develop, I'm giving up my free time to maintain this library.
On Tue, 9 May 2017 at 14:58 Vitaly Tomilov notifications@github.com wrote:
Perhaps the interesting part is that two inserts like this must be executed inside a transaction. Perhaps this is what the author meant to ask about... 😉
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/lukeb-uk/node-promise-mysql/issues/48#issuecomment-300173163, or mute the thread https://github.com/notifications/unsubscribe-auth/AEjy1C1e1IHN7NTlmXg9UgSmsxKC_1Laks5r4HEhgaJpZM4NR0ox .
What are you trying to do?