These are chat archives for crcn/sift.js

5th
Oct 2017
Josh Lloyd
@nevercast
Oct 05 2017 09:15
Hey guys! I love this library! Made adding complex queries to my REST API really easy.

I've made a change at my end and would like to propose it. I've added support for $in[propertyName] which works the same as (propertyName in obj). This let's me check if a property is present in a document without caring for it's value.

I'd like to propose merging this upstream, but thought I'd discuss it with you first. Would you have preferred a different syntax?

The source code currently, keeping in mind I've not put it through it's paces yet.

        if(!(a instanceof Array) && !(b instanceof Array)) {
          for(var key of Object.keys(a)) {
            if(!(key in b)) {
              return false;
            }
          }
          return true;
        } else {
          return !!~a.indexOf(comparableB);
        }

This just goes at the end of the $in handler, and replaces return !!~a.indexOf(comparableB); that stood there before.

Josh Lloyd
@nevercast
Oct 05 2017 09:23
I'd also like to consider doing substring searching. I'd considered using $in operator for that also. {type: $in: { 'banana' } }, { type: 'sweet banana split' } But perhaps using another/new operator is a better option.