Blame view

node_modules/loopback-datasource-juggler/test/kvao/_helpers.js 470 Bytes
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  'use strict';
  
  var Promise = require('bluebird');
  
  exports.givenCacheItem = function(dataSourceFactory) {
    var dataSource = dataSourceFactory();
    return dataSource.createModel('CacheItem', {
      key: String,
      value: 'any',
    });
  };
  
  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;
  };