Explorer

definy.store-write-event

description
Store an event definy checked with the metadata definy read. Nothing happens if it is already stored. created_at_rfc3339 is made from time_ms (SQL)
type
Fn(
  signed_event_bytes: String,
  event_hash: String,
  account_id: String,
  event_type: String,
  time_ms: Number,
  then: Fn(event_hash: String) -> @definy.service-io
) -> @definy.service-io
expression
fn(signed_event_bytes$0, event_hash$1, account_id$2, event_type$3, time_ms$4, then$5) =>
  #sql<@definy.service-io>({
    statements: [
      {
        sql: "INSERT OR IGNORE INTO events (event_hash, signed_event_bytes, account_id, event_type, created_at_rfc3339, time_ms) VALUES (?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', ? / 1000.0, 'unixepoch'), ?)",
        params: [
          #text<@definy.sql-value>($1),
          #text<@definy.sql-value>($0),
          #text<@definy.sql-value>($2),
          #text<@definy.sql-value>($3),
          #integer<@definy.sql-value>($4),
          #integer<@definy.sql-value>($4)
        ]
      }
    ],
    then: fn(results$6) =>
      $5(event_hash: $1)
  })
visibility
public
definy.store-write-event (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: Q5dnCZo1qjVRZhuH4mFR0_PO2VQjwRDI2ttSYHpimpY
content hash: bs0iYigfkZJrS58avDWK-BDKFqC8u5mGDpt7yb_uZNg