Knex database adapter for @expo/entity
. Currently only used with Postgres client.
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),
},
},
{
...
}
);
};