2016-08-08 08:15:22 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-08-15 12:55:26 +00:00
|
|
|
var Promise = require('bluebird');
|
|
|
|
|
2016-08-08 08:15:22 +00:00
|
|
|
exports.givenCacheItem = function(dataSourceFactory) {
|
|
|
|
var dataSource = dataSourceFactory();
|
|
|
|
return dataSource.createModel('CacheItem', {
|
|
|
|
key: String,
|
|
|
|
value: 'any',
|
|
|
|
});
|
|
|
|
};
|
2016-08-15 12:55:26 +00:00
|
|
|
|
|
|
|
exports.givenKeys = function(Model, keys, cb) {
|
|
|
|
var p = Promise.all(
|
|
|
|
keys.map(function(k) {
|
|
|
|
return Model.set(k, 'value-' + k);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
if (cb) {
|
|
|
|
p = p.then(function(r) { cb(null, r); }, cb);
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
};
|