matteodem / meteor-easy-search

Easy-to-use search for Meteor with Blaze Components
MIT License
437 stars 68 forks source link

Return document array instead of object array #508

Closed jannikkeye closed 8 years ago

jannikkeye commented 8 years ago
bildschirmfoto 2016-06-09 um 21 17 37

As you can see above I have to arrays. The above one is from an easy search fetch and the bottom one from a normal meteor collection fetch. I am trying to get the intersection of both with a custom _.intersectionObjects like this

_.intersectionObjects = function(array) {
    var slice = Array.prototype.slice; // added this line as a utility
    var rest = slice.call(arguments, 1);
    return _.filter(_.uniq(array), function(item) {
      return _.every(rest, function(other) {
        //return _.indexOf(other, item) >= 0;
        return _.any(other, function(element) { return _.isEqual(element, item); });
      });
    });
  };

The function runs fine width to arrays returned from a collection.find().fetch().

I am not quite sure if this is the problem but if both arrays contain documents instead of objects the function runs fine.

Is it possible to make easy-search's search().fetch() return an array of documents like the one in the bottom of the picture above.

Thank you in advance!