JavaScript duplex filter - Postgres

The JavaScript duplex filter is a general-purpose filter that can potentially be called for every single packet coming in or going out for a connection.

Parameters

  • Packet types : optional. If specified, a comma-separated list of packet types for which this filter should be called, for instance: Query,Parse,DataRow. Spaces are ignored. If left blank, this filter will get called for every packet sent to and received from the Postgres database server.

Context

The following variables will always be defined when your JavaScript executes:

  • log : the log object

  • context : contains all the variables you'll commonly use:

    • packet : the packet being filtered

    • phase : a string, either "request" or "response"

    • result : the result object, used to cancel the current packet if desired

    • filterContext: an object containing variables attached to this filter. Any changes to this object will be visible to all invocations of this filter.

    • connectionContext: an object containing variables attached to the connection. Any changes to this object will be visible to all filters defined on this connection.