How to insert multiple records into Redis Hash using Lua Script in Node.js

By : Sharath
Source: Stackoverflow.com
Question!

How to insert multiple records into Redis Hash using Lua Script in Node.js

I have the below code which inserts using multi, exec. How to change it using lua script

        return new Promise(function (resolve, reject) 
        {
            // results variable contains data fetched from MySQL db
            results.forEach(function (item) 
            {
                redisClient.hmset('sections:' + item.section_id, item);
            });

            redisClient.exec(function (err, replies) 
            {
                if (err) 
                {
                    console.log(err);
                }
                else 
                {
                    if (results.length == replies.length)
                        console.log("Sections Inserted");
                }

                resolve();
            });

        });
By : Sharath


This video can help you solving your question :)
By: admin