matthewmueller / pogo

Type-safe Database Client for Go. Supports PostgreSQL and SQLite.
MIT License
6 stars 0 forks source link

Pogo

Type-safe Database Client for Go. Supports PostgreSQL and SQLite.

The code is stable and has been in production for many years now including Standup Jack.

Usage

Introspect your database

# connect to a postgres database and build the client in pogo/
pogo --db $(POSTGRES_URL) --schema public --dir ./pogo

Using the Generated Client

pgconfig, err := pgx.ParseURI(env.DatabaseURL)
if err != nil {
  return err
}
db, err := pgx.Connect(pgconfig)
if err != nil {
  return err
}

users, err := user.FindMany(db,
  user.NewFilter().Email("alice@livebud.com"),
  user.NewOrder().CreatedAt(user.DESC),
)

Check out the tests for more usage examples.

Development

Running Tests

To run the tests, you'll need to have PostgreSQL installed locally with an empty pogo database:

createdb pogo
make test

License

MIT