{"repo":"fastify/fastify-mongodb","free":true,"listed":false,"github":"https://github.com/fastify/fastify-mongodb","clone":"git clone https://github.com/fastify/fastify-mongodb.git","description":"Fastify MongoDB connection plugin","language":"JavaScript","stars":270,"topics":["fastify","fastify-plugin","database","mongodb"],"license":"MIT","category":"databases-storage","readme_excerpt":"@fastify/mongodb Fastify MongoDB connection plugin; with this you can share the same MongoDB connection pool in every part of your server. Under the hood the official MongoDB driver is used, the options that you pass to register will be passed to the Mongo client. The mongodb driver is v7.x.x. If you do not provide the client by yourself (see below), the URL option is required . Install Usage Add it to your project with register and you are done! You may also supply a pre-configured instance of mongodb.MongoClient : Notes: the passed client connection will not be closed when the Fastify server shuts down. to terminate the MongoDB connection you have to manually call the fastify.close method (for example for testing purposes, otherwise the test will hang). mongodb connection timeout is reduced from 30s (default) to 7.5s to throw an error before fastify plugin timeout. Reference This plugin decorates the fastify instance with a mongo object. That object has the following properties: client is the MongoClient instance ObjectId is the ObjectId class db is the DB instance The ObjectId class can also be directly imported from the plugin as it gets re-exported from mongodb : The db property is added only if : a database string option is given during the plugin registration. the connection string contains the database name. See the Connection String URI Format A name option can be used to connect to multiple MongoDB clusters. Acknowledgments This project is kindly sponsored by: nearF","default_branch":null,"files":null,"tree":[],"storefront":"/r/fastify","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/fastify/fastify-mongodb/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}