Trying to insert 20 records inside the data array for a key in redis and for that purpose and for that purpose we have written the function as below
async function writeRecord(number){
let reply = await client.hGetAll(hashKey);
dataArray = reply.dataArray ? JSON.parse(reply.dataArray) : [];
dataArray.push({pipelineId: number,status: 'inserted'});
await client.hSet(hashKey,'dataArray', JSON.stringify(dataArray));
}
for (let i = 0; i < 20; i++){
( async()=>{await writeRecord(i)}) (); ;
}
but in this scenario only the last record {pipelineId: 19 ,status:’inserted’} is being shown in the redis, we need to all records from pipeline:1 to pipelineId: 19.
While debugging the hGetAll always gives {} since initially we dont have any record in redis