0.2.0 • Published 1 year ago

@yadah/objection-iterator v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Objection Iterator mixin

A mixin for Objection.js Model classes that allows using queries as async iterables. It allows streaming query results!

Usage

import { mixin, Model } from "objection";
import IteratorMixin from "@yadah/objection-iterator";

class MyModel extends mixin(Model, [IteratorMixin]) {
  static tableName = "mytable";

  async doSomething() {
    //
  }
}

for await (const model of MyModel.query()) {
  model instanceof MyModel; // true
  await model.doSomething();
}