Still struggling to get my head around .bind
.
If I have...
dbAccess.runCommand('INSERT INTO users (email) values (?); SELECT LAST_INSERT_ID()',
req.getConnection,
email)()
.then(setProjectPermission(req, res, 'insertId', projectId, permissionLevel));
and....
function setProjectPermission(req, res, arg, projectId, permissionLevel) {
return function(result) {
var id = result.rows[0][arg];
...
Can I use .bind
so I don't have to use a function which returns a function? I'm struggling to know how to make the anonymous closure. For example if it was EC6 I would do this (I think)...
dbAccess.runCommand('INSERT INTO users (email) values (?); SELECT LAST_INSERT_ID()',
req.getConnection,
email)()
.then(result => setProjectPermission(req, res, result.insertId, projectId, permissionLevel));
and....
function setProjectPermission(req, res, idArg, projectId, permissionLevel) {
var id = idArg;
...
Is this possible to do without returning the function which is expecting 'result' ?