UNPKG

@blueleader07/typeorm

Version:

Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.

36 lines (34 loc) 1.02 kB
import { Stream } from "stream"; export class DynamoReadStream extends Stream.Readable { constructor(repository, options) { super(); this.repository = repository; this.options = options; } _read() { this.repository .scan(this.options) .then((items) => { if (items.length > 0) { for (let i = 0; i < items.length; i++) { const item = items[i]; this.push(item); } if (items.LastEvaluatedKey) { this.options.exclusiveStartKey = items.LastEvaluatedKey; } else { this.push(null); } } else { this.push(null); } }) .catch((error) => { console.error(error); throw new Error("failed to stream dynamodb results"); }); } } //# sourceMappingURL=DynamoReadStream.js.map