Monday 5 June 2017

Not update properly in update sequelize in nodejs

please let me know why some records are not updated properly. Shall I add promises(bluebird) in following statement? If yes, please let me know how to add it. Thanks in advance.

companies.forEach(function (company) {
    var replacements = {};
    return models.sequelize.query(SQL_STATEMENT, {
        type: sequelize.QueryTypes.SELECT,
        nest: true,
        replacements: {
            companyId: company.id
        }
    }).then(function(results) {
        results.forEach(function (result) {
            return company.updateAttributes({
                conversion_code: result.color
            });
        });
    });
})



via ppshein

No comments:

Post a Comment