|
const etlCharacteristicReviews = () => { |
|
const readable = fs.createReadStream(characteristicReviews); |
|
readable |
|
.pipe(csv({})) |
|
.on('data', async (data) => { |
|
let transformedData = [Number(data.id), Number(data.characteristic_id), Number(data.review_id), Number(data.value)]; |
|
await db.insertIntoCharacteristicsReviews(transformedData); |
|
}) |
|
.on('data', () => { |
|
readable.pause(); |
|
setTimeout(() => { |
|
// console.log('Now data starts flowing again.'); |
|
readable.resume(); |
|
}, 1000); |
|
}) |
|
.on('end', () => { |
|
console.log('INSERTED ALL CHARACTERISTICS REVIEWS INTO PHOTOS!!!!!!!!!!!!'); |
|
}); |
|
} |
Make sure we're handling errors within the process. You'll need to handle errors for the stream as well as errors with mongoose
Reviews-API/src/etl/etl_characteristics_reviews.js
Lines 7 to 25 in b7769c4
Make sure we're handling errors within the process. You'll need to handle errors for the stream as well as errors with mongoose