The mongoOptions is provided to the the standard mongodb client. All the available options are described on its official documentation.
Note that you may encouter missing logs in special cases: it dependes on data and mongo's version. Please checkout the mongodb limitation official documentation.
For example on MongoDB 4:
// IT DOES NOT WORK:log.info({ $and: [{ a: 1 }, { b: 2 }] }, 'my query is')// IT WORKS:log.info({ query: { $and: [{ a: 1 }, { b: 2 }]} }, 'my query is')
If you want a custom parser to handle the above case. You need to wrap pino-mongo and pass a function through option.parseLine. Any value that is not a function will be ignored in this option.
// mongo-transport.js'use strict'const transport = require('pino-mongodb')module.exports = function(opts) { opts.parseLine = function(str) { // `str` is passed from `pino` and expected to be a string const obj = JSON.parse(str) // do anything you want... return obj // return value is expected to be a json that will pass and save inside mongodb } return transport(opts)}// main.jsconst pino = require('pino')const transport = pino.