New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

keyv-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keyv-mongodb

MongoDB storage adapter for Keyv with support for Mongoose

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.5K
decreased by-1.68%
Maintainers
1
Weekly downloads
 
Created
Source

keyv-mongodb

MongoDB storage adapter for Keyv with support for Mongoose

Installation

mongodb and mongoose are both peerDependecies. Install either one (or both) you'll be using with this package.

yarn add keyv keyv-mongodb mongoose
# or
yarn add keyv keyv-mongodb mongodb

Compatibility

  • Support Mongoose >= 6
  • Support native MongoDB driver >= 4
  • Support Node.js 10-17

Connection to MongoDB

Re-use a Mongoose connection
const mongoose = require('mongoose')

mongoose.connect(connectionOptions)

const keyv = new Keyv({
	store: new KeyvMongoDB({ mongooseConnection: mongoose.connection }),
})
Re-use a native MongoDB driver connection (or a promise)
const keyv = new Keyv({
	store: new KeyvMongoDB({ db: dbInstance }),
})

Or just give a promise...

const keyv = new Keyv({
	store: new KeyvMongoDB({ dbPromise: dbInstancePromise }),
})
Create a new connection from a MongoDB connection string

MongoDB connection strings are the best way to configure a new connection. For advanced usage, more options can be configured with mongoOptions property.

const keyv = new Keyv({
	store: new KeyvMongoDB({ url: 'mongodb://localhost/test-app' }),
})

License

ISC License

Based on work from

Keywords

FAQs

Package last updated on 19 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc