title: Save a stream of data in a column of PostgreSQL using TypeORM
body: <p>I need to save a big csv file content in a column of my table. I have tried using buffer, but it is returning <code>FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory</code>, is it a way to save it using stream, i.e, store just part of the csv in memory, not the whole csv data?</p>
  
  <p>Storing the whole CSV in memory:</p>
  
  <pre><code>let content = [];
     let bufferContent = null;
     await (new Promise(resolve =&gt; {
       notificationRequest.usersStream
         .on(‘data’, function(buffer) {
           content.push(buffer);
         })
         .on(‘end’, function() {
           bufferContent = Buffer.concat(content);
           resolve();
         });
     }));
  </code></pre>
  
  <p>Trying to save the buffer in DB: </p>
  
  <pre><code>this.dbRepository.save(bufferContent);
  </code></pre>
  
  <p>Gives me the error:</p>
  
  <pre><code>FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
  </code></pre>
  
  <p>TypeORM Entity</p>
  
  <pre><code>@Column({ type: ‘bytea’, nullable: true})
   csvBuffer?: Buffer;
  </code></pre>
  
  <p>PS: If the file is small the code above works perfectly.</p>