sequelize-pg-stream
v0.0.4
Published
Make model classes streamable when using PG
Downloads
17
Readme
sequelize-pg-stream
Make model classes streamable when using PG, adding .findAllStream
function.
Getting Started
To install:
npm i --save sequelize-pg-stream
Stream support for model:
const Sequelize = require('sequelize')
const sequelizePgStream = require('sequelize-pg-stream')
const sequelize = new Sequelize('database', 'username', 'password', {/*options*/})
const Items = sequelize.define('items',{
n: sequelize.INTEGER,
s: {
type: sequelize.STRING,
primaryKey: true
})
sequelizePgStream.streamFromModel(Items)
await sequelize.sync()
const itemsStream = await Items.findAllStream()
itemsStream
.on('data', (itemModel) => {
// do somethings
})
.pipe(/* do somethings */)