Response Filters - MongoDB
Response filters are filters that get invoked when the database server sends a response back to the database client.
Context
All response filters define the following variables, which can be accessed from your JavaScript code:
log : A Logger object to output messages to the logging system
context : a container object with the following properties:
packet : the packet being processed - can be any response packet type, or a result set object depending on the filter
packetType : the type of the packet, equivalent to context.packet.getPacketType()
filterContext : the variables that persist through the life of the filter
adapterContext : the variables that persist through the life of this database connection
Response filters for MongoDB
JavaScript response filter : is (potentially) invoked for every response packet. The packet type can be specified.
Message response filter : is invoked for every response packet of type MSG, can be qualified by the content of the message.
Result set filter: is invoked for response packets of type MSG that contain a cursor property. This allows for easy filtering of responses to MSG-based queries (i.e. most modern queries)
Reply response filter : invoked for response packets of type REPLY. Rarely used nowadays except for authentication and other admin-type activity.