Explorer

definy.store-read-raw-content

description
Read a content of the store by the key (a content hash or a name). content_hash is the SHA-256 of the bytes (SQL)
type
Fn(key: String, then: Fn(content: Union{#none, #some(@definy.raw-content)}) -> @definy.service-io) -> @definy.service-io
expression
fn(key$0, then$1) =>
  #sql<@definy.service-io>({
    statements: [
      {
        sql: "SELECT content_bytes FROM cas_contents WHERE content_hash = ?",
        params: [#text<@definy.sql-value>($0)]
      }
    ],
    then: fn(results$2) =>
      match @core.list-get(list: @definy.sql-rows-concat(results: $2, index: 0), index: 0) {
        #some(row$3) =>
          let bytes$4 = @definy.sql-text(row: $3, name: "content_bytes");
          #hash_contents<@definy.service-io>({
            contents_bytes: [$4],
            then: fn(hashes$5) =>
              match @core.list-get(list: $5, index: 0) {
                #some(hash$6) =>
                  match $6 {
                    #some(content_hash$7) =>
                      $1(content: #some({content_hash: $7, bytes_base64: $4})),
                    #none(_) =>
                      $1(content: #none)
                  },
                #none(_) =>
                  $1(content: #none)
              }
          }),
        #none(_) =>
          $1(content: #none)
      }
  })
visibility
public
definy.store-read-raw-content (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: fxtvbUwI7PHqprC3uPiibgzwrl9Mkhvb8apEB4BlZK8
content hash: 7W9Cq_8H0rBgmHKpoRpU7Fgb8xoCAWelLVdtK4DaBkQ