A database adapter for PostgreSQL using TypeORM

It is our long-term goal for typeorm package to be database agnostic and support all database types it does by default. For now it only works and has been tested with PostgreSQL, feel free to explore other typeorm-integrations.


yarn add @accounts/typeorm typeorm pg


import { createConnection } from 'typeorm';
import { AccountsServer } from '@accounts/server';
import { AccountsTypeorm, entities } from '@accounts/typeorm';
type: 'postgres',
url: 'postgres://user@localhost:5432/dbname',
}).then(() => {
const accountsTypeorm = new AccountsTypeorm({
// options
const accountsServer = new AccountsServer(
{ db: accountsTypeorm },
// services


You can use the following options to configure the @accounts/typeorm behavior.

interface AccountsTypeormOptions {
cache?: undefined | number;
connection?: Connection;
connectionName?: string;
userEntity?: typeof User;
userServiceEntity?: typeof UserService;
userEmailEntity?: typeof UserEmail;
userSessionEntity?: typeof UserSession;

Extending entities

If you want to add fields, etc. to the User entity you can, by extending the base entities.

import { User as AccountsUser } from '@accounts/typeorm';
export class User extends AccountsUser {
// Add fields
custom_field: string;
// Overwrite fields
profile: string;


A working example using the database-typeeorm package with a PostgreSQL database is available here.

Last updated on