mongodb-keyval-storage
v1.0.0
Published
MongoDB token storage for Passport Magic Link
Downloads
4
Maintainers
Readme
mongodb-keyval-storage
Key Value Storage for MongoDB with a simple API
Installation
npm install mongodb-keyval-storage
Usage
Configure Strategy
The MongoStorage constructor receives two parameters:
db
: A MongoDB database connection or a connection string.collectionName
: The name of the collection used to save the data.
const storage = new MongoStorage({
db: 'mongodb://localhost:27017/db',
collectionName: 'myCollection'
})
API
Set
Adds a value with it's respective key to the database. Returns a promise.
await storage.set('key', 'value')
Get
Returns promise that resolves to a value given it's respective key.
const value = await storage.get('key')
Delete
Removes the key and value from the database, given the key. Returns a promise.
await storage.delete('key')