Search code examples
postgresqlpg-promise

How to use pgp.as.format for a transaction


Is it possible to use pgp.as.format to see raw postgres queries generated by a transaction db.tx(t => ...)? I can't figure out the syntax for this use-case.


Solution

  • If you can't figure out what query is generated, you have the following options:

    • Start using pg-monitor that will show you all the queries automatically
    • Manually connect to event query
    • Use function as.format

    Is it possible to use pgp.as.format

    Why wouldn't it be possible? The function is there to be used independently whenever needed. But in your case, for viewing generated queries, the other two options are better.