How to implement transaction in knex if functions are used? util.insert calls knex on table2 and similarly util.mark.

 knex('tab1').where({ col1: 'val1' }).update({ col2: 'val2'}).returning('col3').then(function(result1) {
                    if (result1 != 0) {
                        var data2 = {
                            "key": "value"
                        };
                      util.insert(data1, function(err1, data2) {
                            if (err1) {
                                cb(err1);
                                return;
                            }
                            util.mark(data2, function(err2, data3) {
                                if (err2) {
                                    cb(err2);
                                    return;
                                }
                                cb(null, true);
                                return;
                            });
                        });
                    } else {
                        cb(null, false);
                    }
                })
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.