Explorer

definy.store-read-events

description
The events stored with the hashes (in the same order. none if not stored) (SQL)
type
Fn(
  event_hashes: List<String>,
  then: Fn(events: List<Union{#none, #some(@definy.stored-event)}>) -> @definy.service-io
) -> @definy.service-io
expression
fn(event_hashes$0, then$1) =>
  #sql<@definy.service-io>({
    statements: @definy.sql-in-statements(
      prefix: "SELECT event_hash, signed_event_bytes, account_id, event_type, created_at_rfc3339, time_ms FROM events WHERE event_hash IN ",
      items: $0
    ),
    then: fn(results$2) =>
      let rows$3 = @definy.sql-rows-concat(results: $2, index: 0);
      let row_index$9500 = @definy.sql-row-index(rows: $3, name: "event_hash");
      $1(
        events: @core.list-map(
          T: String,
          U: Union{#none, #some(@definy.stored-event)},
          f: fn(item$4) =>
            match @definy.sql-row-find(index: $9500, value: $4) {
              #some(row$5) =>
                #some(@definy.stored-event-of-row(row: $5)),
              #none(_) =>
                #none
            },
          xs: $0
        )
      )
  })
visibility
public
definy.store-read-events (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: CQ-pC0EE8nU9fIMtYkCCb-itZqZq-p1BjDmXAgQBa5Q
content hash: Xmh9fy3naVkjSik3bISaivlSGo0nEedEVqoi6QAWu1Q