1.8.0 • Published 2 years ago

quackatos v1.8.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

🦆 quackatos

NPM Test

Quackatos is an extremely well-typed query builder for Postgres, built on top of the excellent Zapatos library.

For example:

import q from "quackatos"
import { Pool } from "pg"

const pool = new Pool()

const filmAndActor = await q("film")
  .leftJoin("film_actor", "film.film_id", "film_actor.film_id")
  .leftJoin("actor", "actor.actor_id", "film_actor.actor_id")
  .select("actor.first_name", "film.*")
  .limit(1)
  .run(pool)

// typeof filmAndActor ===
//  film.Selectable &
//  Pick<NullPartial<actor.Selectable>, "first_name">

Setup

First, you'll have to set up Zapatos (Quackatos relies on Zapatos for type generation and helper functions).

Then:

yarn add quackatos or npm install quackatos

Goals

If it looks like a duck, swims like a duck, and quacks like a duck, then it's probably a duck.

Quackatos has three main goals:

  • Query results should be strongly typed to the fullest extent possible
  • Any code without type errors should generate a valid query
  • It should be immediately obvious what Postgres query will be generated for any given code

Quackatos does not intend to be a drop-in replacement for Knex, though it shares much of the same syntax.

Related Works

  • Knex: a weakly-typed query builder for many different database engines
  • Prisma: a strongly-typed ORM for many different database engines
  • Zapatos: a type generation and query helper library for Postgres

Contributing

See CONTRIBUTING.md for details.

1.8.0

2 years ago

1.7.0

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago