Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Daniel Hood
    @hooddanielc
    Hai,
    does sift support nested operators?
    Robert
    @Sweet-Bob
    Guys! Your library awesomeeee!!! :) thank you
    Craig Condon
    @crcn
    Glad you like it :)
    Konstantin Baierer
    @kba
    Hi, it's a fantastic library indeed!
    In case anyone's interested, I've written a plugin to filter by date here: https://github.com/kba/sift-date
    And I'm using sift for creating rule systems with https://github.com/kba/sift-rule
    This kinda inverts the logic where you don't want to filter an array but find out which filters match.
    Very useful for permissions and such.
    Sergii Stotskyi
    @stalniy
    is there a way to find by ObjectId?
    Josh Lloyd
    @nevercast
    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
    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.
    Konstantin Baierer
    @kba
    @nevercast Isn't your $in operator on objects the same as $exists?
    Since sift.js is far less widely used, keeping operators compatible with MongoDB seems wise.
    Your $in substring operator would be like a shortcut for using a regex as the value of a query k-v-pair?
    Some mongo wrappers offer a $regex operator for that.