Explorer

definy.sql-run-chunks

description
Run the statements from start, 50 at a time (each 50 in one batch)
type
Fn(
  statements: List<@definy.sql-statement>,
  start: Number,
  then: Fn(done: Boolean) -> @definy.service-io
) -> @definy.service-io
expression
fn(statements$0, start$1, then$2) =>
  let length$3 = @core.list-length(value: $0);
  match @core.less-than(left: $1, right: $3) {
    false =>
      $2(done: true),
    true =>
      #sql<@definy.service-io>({
        statements: @std.list-range(
          T: @definy.sql-statement,
          list: $0,
          start: $1,
          end: @std.min(a: @core.plus(left: $1, right: 50), b: $3)
        ),
        then: fn(results$4) =>
          @definy.sql-run-chunks(
            statements: $0,
            start: @core.plus(left: $1, right: 50),
            then: fn(done$5) =>
              $2(done: $5)
          )
      })
  }
visibility
public
definy.sql-run-chunks (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: tlt4IFIb8P7URF60MYudJjgTEJ-iAej7toWIMjqv6mM
content hash: NDi7eR_jXMx6NPn9i-kckilckfnt_iodMnWkfaUAMHI