import Knex from "knex" ; import _ from "lodash" ; const config = require ( "../../config.development.json" ) ; export const knex = Knex ( { ... config . database , wrapIdentifier , } ) ; const wrappedIdentCache = Object . create ( null ) ; const camelizedFieldNameCache = Object . create ( null ) ; function typeCast ( field , next ) { field . packet . name = camelizedFieldNameCache [ field . name ] || ( camelizedFieldNameCache [ field . name ] = _ . camelCase ( field . name ) ) ; return next ( ) ; } function wrapIdentifier ( value , origImpl ) { return ( wrappedIdentCache [ value ] || ( wrappedIdentCache [ value ] = value === "*" ? value : origImpl ( _ . snakeCase ( value ) ) ) ) ; } knex . client . connectionSettings . typeCast = typeCast ;