@expo/entity-database-adapter-knex
v0.39.0
Published
Knex database adapter for @expo/entity
Downloads
1,100
Maintainers
Keywords
Readme
@expo/entity-database-adapter-knex
Knex database adapter for @expo/entity
. Currently only used with Postgres client.
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),
},
},
{
...
}
);
};