glv8

Ever wanted to write functional type-safe postgresql procedures ? Let’s use gleam !

Package Version Hex Docs

glv8 coworks with plv8. It provides plv8’s API bindings so one can write procedures with gleam and let plv8 do the needed proxying. Specifically, gleam codes are compiled as JavaScript and interoperate with plv8 ecosystem. For example

pub fn catch_sql_error() -> Nil {
  let r = database.execute("throw SQL error", Nil)
  use <- bool.guard(result.is_ok(r), Nil)

  case r {
    Error(glv8.DBErrorJson(j)) -> elog_notice(j |> json.to_string)
    _ -> elog_notice("should not come here")
  }
}

The snippet can be provisioned with plv8 declaration

CREATE FUNCTION catch_sql_error() RETURNS void AS
$$
  glv8.catch_sql_error();
$$ LANGUAGE plv8;

More examples can be found at src/app/plv8.gleam Further documentation can be found at https://hexdocs.pm/glv8.

Development

$ npm run build
$ npm run watch
$ npm run clean
$ npm run purge

Deployment

RoadMap

Search Document