PostgreSqlConnection
Hierarchy
- AbstractSqlConnection
- PostgreSqlConnection
Index
Constructors
constructor
Parameters
config: Configuration<IDatabaseDriver<Connection>, EntityManager<IDatabaseDriver<Connection>>>
optionaloptions: ConnectionOptions
optionaltype: read | write
Returns PostgreSqlConnection
Methods
begin
Parameters
options: { ctx?: Transaction<any, any[]>; eventBroadcaster?: TransactionEventBroadcaster; isolationLevel?: IsolationLevel; readOnly?: boolean } = {}
optionalctx: Transaction<any, any[]>
optionaleventBroadcaster: TransactionEventBroadcaster
optionalisolationLevel: IsolationLevel
optionalreadOnly: boolean
Returns Promise<Transaction<any, any[]>>
checkConnection
Returns Promise<{ error?: Error; ok: boolean; reason?: string }>
close
Closes the database connection (aka disconnect)
Parameters
optionalforce: boolean
Returns Promise<void>
commit
Parameters
ctx: Transaction<any, any[]>
optionaleventBroadcaster: TransactionEventBroadcaster
Returns Promise<void>
connect
Establishes connection to database
Returns void | Promise<void>
createKnex
Returns void
ensureConnection
Ensure the connection exists, this is used to support lazy connect when using
MikroORM.initSync()
Returns Promise<void>
execute
Type parameters
- T: QueryResult<{ id: number }> | EntityData<Partial<any>> | EntityData<Partial<any>>[] = EntityData<Partial<any>>[]
Parameters
queryOrKnex: string | QueryBuilder<any, any> | Raw<any>
params: unknown[] = []
method: get | all | run = 'all'
optionalctx: any
optionalloggerContext: LoggingOptions
Returns Promise<T>
getClientUrl
Returns string
getConnectionOptions
Returns PgConnectionConfig
getDefaultClientUrl
Returns default client url for given driver (e.g. mongodb://127.0.0.1:27017 for mongodb)
Returns string
getKnex
Returns Knex<any, any[]>
getPlatform
Returns Platform
isConnected
Are we connected to the database
Returns Promise<boolean>
loadFile
Execute raw SQL queries from file
Parameters
path: string
Returns Promise<void>
rollback
Parameters
ctx: Transaction<any, any[]>
optionaleventBroadcaster: TransactionEventBroadcaster
Returns Promise<void>
setMetadata
Parameters
metadata: MetadataStorage
Returns void
setPlatform
Parameters
platform: Platform
Returns void
transactional
Type parameters
- T
Parameters
cb: (trx: Transaction<any, any[]>) => Promise<T>
options: { ctx?: Transaction<any, any[]>; eventBroadcaster?: TransactionEventBroadcaster; isolationLevel?: IsolationLevel; readOnly?: boolean } = {}
optionalctx: Transaction<any, any[]>
optionaleventBroadcaster: TransactionEventBroadcaster
optionalisolationLevel: IsolationLevel
optionalreadOnly: boolean
Returns Promise<T>
Are we connected to the database