Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. const StreamArray = require('stream-json/streamers/StreamArray');
  2. const path = require('path');
  3. const fs = require('fs');
  4.  
  5. const jsonStream = StreamArray.withParser();
  6. // 1-> get JOB ID from cmd args
  7. // 2 -> get filename/path from table for given hob ID.
  8. //
  9. //You'll get json objects here
  10.  
  11. //Key is an array-index here
  12. var start = new Date()
  13. jsonStream.on('data', ({ key, value }) => {
  14. console.log(key, value);
  15. });
  16.  
  17. jsonStream.on('end', () => {
  18. console.log('All done');
  19. // 1-> UPdate job status for as success for given JOb id
  20.  
  21. });
  22.  
  23. // const data_dir = "c://"
  24. //if JOB failed mark job as failed for given job ID.
  25. const filename = path.join(__dirname, 'temp.json');
  26. fs.createReadStream(filename).pipe(jsonStream.input);
  27. var end = new Date() - start
  28. console.info('Execution time: %dms', end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement