All files / app/lib/elasticsearch find.js

100% Statements 32/32
80% Branches 8/10
100% Functions 3/3
100% Lines 32/32

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 3221x 21x 21x 2x 2x 2x 1x 1x 2x 1x 1x 1x 2x 21x 21x 21x 21x 1x 21x 21x 21x 1x 1x 1x 1x 3x 3x 1x 1x 21x 21x 21x
const Streamz = require('streamz');
const util = require('util');
 
function Find(client,options) {
  if (!(this instanceof Find))
    return new Find(client);
 
  if (!client)
    throw 'CLIENT_MISSING';
 
  Streamz.call(this,options);
  this.client = client;
}
 
util.inherits(Find,Streamz);
 
Find.prototype.search = function(d) {
  return this.client.search(d);
};
 
Find.prototype._fn = function(query) {
  return this.search(query)
    .then(d => {
      if (d.body) d = d.body;
      d.hits.hits.forEach(d => {
        d._search = query;
        this.push(d);
      });
    });
};
 
module.exports = Find;