Skip to main content
For each table in your database you need to create a class and decorate it with the @Table decorator. Once you do this we call the class an . For each column in each table create a field in the class and decorate it with the @Column decorator. Make sure the arguments passed to the @Column decorator match the column attributes in the database. Every needs to have a . Example:
/entities/users.ts
@Table("users")
export class Users {
  @PrimaryKey({ name: "id", type: "UUID" })
  id: string;

  @Column({ name: "username", type: "TEXT" })
  username: string;
}
You can read more about defining tables here

Client

Initialize a :
tygress-client.ts
import { Users } from "./entities";
import { PostgresClient } from "tygress";

export default new PostgresClient({
  databaseUrl: "postgres://username:password@host:5432/database",
  entities: [Users], // List all your tables here
});

Usage

Elsewhere in your application you can run queries like this:
index.ts
import DB from 'tygress-client.ts'

const users = await DB.select(Users, { where: { username: 'batman' }})

Migrations

If you want to manage your database using Tygress you should read more about migrations ->

Continue reading

Keep learning how to use Tygress