INNER CODE UNIT · JavaScript

decorateFastifyInstance

fastify/fastify-mongodb · index.js:6

function decorateFastifyInstance (fastify, client, options) {
  const { forceClose, database, name, newClient } = options

  if (newClient) {
    // done() is not needed because .close() returns a Promise
    fastify.addHook('onClose', function closeMongoDb () {
      return client.close(forceClose)
    })
  }

  const mongo = {
    client,
    ObjectId
  }
  if (name) {
    if (!fastify.mongo) {
      fastify.decorate('mongo', mongo)
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…