Hi I have async nodejs function where I am using stream concept. I want once stream is completed then I want to return from this function.
const removeMapping = async function (query) {
    let stream = query.foreach();
    stream.on('data', function (record) {
       client.delete(record);
    })
    stream.on('error', function (error) {
    })
    stream.on('end', function () {
        console.log("completed");
    })
};
I am calling this function like this but after execution of this line, stream async code after this.
await mapping.deleteMapping(cookie);
Does anyone know how to handle this ?
 
    