UNPKG

mongo-milestone

Version:

*A life-saving little tool to work around the lack of ACID Transactions in MongoDB*

40 lines (29 loc) 1.31 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.setup = exports.getConfig = exports.resetDefaults = exports.JOBS_COLLECTION_NAME = exports.RETRY_TIMESPAN = exports.MONGO_CONNECTION_STRING = undefined; var _q = require('q'); var _q2 = _interopRequireDefault(_q); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const MONGO_CONNECTION_STRING = exports.MONGO_CONNECTION_STRING = 'mongoConnectionString'; const RETRY_TIMESPAN = exports.RETRY_TIMESPAN = 'retryTimespan'; const JOBS_COLLECTION_NAME = exports.JOBS_COLLECTION_NAME = 'jobsCollectionName'; const resetDefaults = exports.resetDefaults = () => { Object.assign(config, { mongoConnectionString: null, retryTimespan: 30, jobsCollectionName: '__milestones__' }); }; const config = {}; resetDefaults(); const getConfig = exports.getConfig = path => { return config[path]; }; const setup = exports.setup = (mongoConnectionString, retryTimespan, jobsCollectionName) => { config.mongoConnectionString = mongoConnectionString || config.mongoConnectionString; config.retryTimespan = retryTimespan || config.retryTimespan; config.jobsCollectionName = jobsCollectionName || config.jobsCollectionName; return config; };