The list of known connections to registers.
The new function.
import { createWithPostgres } from "@egomobile/orm-pg"
// `EntityConfigurations` objects, returned by functions
// exported as `default`s
import getDefaultEntityConfiguration from './entities/default'
import getTestEntityConfiguration from './entities/test'
const withPostges = createWithPostgres({
"default": {
"client": null, // read `pg` config from environment variables
"entities": getDefaultEntityConfiguration()
},
"test1": {
"client": 'postgresql://dbuser:secretpassword@database.server.com:3211/mydb',
"entities": getTestEntityConfiguration()
}
})
// `defaultResult` === "FOO"
const defaultResult = await withPostges('default', async (defaultContext) => {
// do something with `default` connection in `defaultContext`
return "FOO"
})
// `test1Result` === "bar"
const test1Result = await withPostges('test1', async (test1Context) => {
// do something with `test1` connection in `test1Context`
return "bar"
})
Generated using TypeDoc
Creates a function, which runs itself an action inside an open PostgreSQL connection.