@expo/entity-database-adapter-knex
TypeScript icon, indicating that this package has built-in type declarations

0.39.0 • Public • Published

@expo/entity-database-adapter-knex

Knex database adapter for @expo/entity. Currently only used with Postgres client.

Documentation

Usage

During EntityCompanionProvider instantiation:

import { knex, Knex } from 'knex';

const knexInstance = knex({
  client: 'pg',
  connection: {
    user: process.env['PGUSER'],
    password: process.env['PGPASSWORD'],
    host: process.env['PGHOST'],
    port: parseInt(nullthrows(process.env['PGPORT']), 10),
    database: process.env['PGDATABASE'],
  },
});

export const createDefaultEntityCompanionProvider = (
  metricsAdapter: IEntityMetricsAdapter = new NoOpEntityMetricsAdapter()
): EntityCompanionProvider => {
  return new EntityCompanionProvider(
    metricsAdapter,
    {
      // add the knex database adapter flavor
      ['postgres']: {
        adapter: PostgresEntityDatabaseAdapter,
        queryContextProvider: new PostgresEntityQueryContextProvider(knexInstance),
      },
    },
    {
      ...
    }
  );
};

Readme

Keywords

Package Sidebar

Install

npm i @expo/entity-database-adapter-knex

Weekly Downloads

225

Version

0.39.0

License

MIT

Unpacked Size

237 kB

Total Files

79

Last publish

Collaborators

  • douglowder
  • betoatexpo
  • philpl
  • expo-bot
  • szdziedzic
  • alanhughes
  • kadikraman
  • radoslawkrzemien
  • aleqsio
  • marklawlor
  • gabrieldonadel
  • simek
  • keith-kurak
  • fiber-god
  • ide
  • brentvatne
  • evanbacon
  • quinlanj
  • expoadmin
  • tsapeta
  • exponent
  • wschurman
  • bycedric
  • lukmccall
  • jonsamp
  • princefleaswallow
  • kudochien