1.1.0 • Published 7 years ago

frivillig-db v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

Frivillig DB

Wraps MongoClient to (hopefully) further ease using Mongo! Features a built in cache, which stores data in-memory for one hour before fetching fresher data.

Usage

const options = {
  logger: console.log,
  databaseUri: 'mongodb://localhost:27107/test',
  disableCache: false
};

const { getCachedQuery, createCacheKey, getDatabase } = require('frivillig-db')(options);

module.exports = {
    const cacheKey = createCacheKey('collectionName');
    findItem(itemId) {
        return getCachedQuery(cacheKey, database => {
            return database.collection('collectionName').findOne({ trackingId });
        });
    }
};

Development

If you do not want to cache things, for whatever reason, you can disable it by passing disableCache: true in the configuration.