MongoDB storage adapter for Keyv with support for Mongoose
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- Support Mongoose
>= 6 - Support native MongoDB driver
>= 4 - Support Node.js >=10
const mongoose = require('mongoose')
mongoose.connect(connectionOptions)
const keyv = new Keyv({
store: new KeyvMongoDB({ mongooseConnection: mongoose.connection }),
})const keyv = new Keyv({
store: new KeyvMongoDB({ db: dbInstance }),
})Or just give a promise...
const keyv = new Keyv({
store: new KeyvMongoDB({ dbPromise: dbInstancePromise }),
})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' }),
})ISC License
Based on work from