@keyvhq/mongo
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

@keyvhq/mongo keyv

MongoDB storage adapter for Keyv.

Uses TTL indexes to automatically remove expired documents. However MongoDB doesn't guarantee data will be deleted immediately upon expiration, so expiry dates are revalidated in Keyv.

Install

npm install --save @keyvhq/core @keyvhq/mongo

Usage

NOTE: The mongo uses url instead of uri to provide the connection string details.

const KeyvMongo = require('@keyvhq/mongo')
const Keyv = require('@keyvhq/core')

const keyv = new Keyv({
  store: new KeyvMongo('mongodb://user:pass@localhost:27017/dbname')
})

You can specify the collection name, by default 'keyv' is used:

const KeyvMongo = require('@keyvhq/mongo')
const Keyv = require('@keyvhq/core')

const keyv = new Keyv({
  store: new KeyvMongo('mongodb://user:pass@localhost:27017/dbname', {
    collection: 'cache'
  })
})

License

@keyvhq/mongo © Luke Childs, released under the MIT License.
Maintained by Microlink with help from contributors.

microlink.io · GitHub microlinkhq · Twitter @microlinkhq

Package Sidebar

Install

npm i @keyvhq/mongo

Homepage

keyv.js.org

Weekly Downloads

61

Version

2.1.1

License

MIT

Unpacked Size

8.08 kB

Total Files

5

Last publish

Collaborators

  • kikobeats
  • jytesh