Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ordermentum/sequelize-batches
https://github.com/ordermentum/sequelize-batches
async-await iterator nodejs sequelize
Last synced: about 14 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/ordermentum/sequelize-batches
- Owner: ordermentum
- License: apache-2.0
- Created: 2017-08-23T22:19:47.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T17:58:26.000Z (11 months ago)
- Last Synced: 2024-11-02T10:08:25.753Z (13 days ago)
- Topics: async-await, iterator, nodejs, sequelize
- Language: JavaScript
- Size: 91.8 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sequelize Batches/Iterators
*Note: depends on async generators*
works with Node 8.4.0 ```node --harmony-async-iteration```
## Install
```bash
yarn add sequelize-batches
```Below where you have imported sequelize add sequelize-batches
```javascript
const Sequelize = require('sequelize');
require('sequelize-batches');
```## Usage
Below example queries using the new syntax
```javascript
for await (const posts of Post.batch({
where: { userId: 1 },
batchSize: 1000 })) {
for (const post of posts) {
console.log(post);
}
}for await (const post of Post.iterator()) {
console.log(post);
}for await (const post of Post.iterator({
where: {
id: {
$gte: 900,
}
}
})) {
console.log(post.title);
}
```