GithubHelp home page GithubHelp logo

filterable's People

Contributors

diversen avatar samypesse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

filterable's Issues

Filter a local array

Hi

Is it possible currently to filter an array based on its objects inside.
What i want to achieve is a local filter option, every time you have some grid, doing individual filter boxes for multiple properties its tedious, having just one box to filter based on this syntax which is pretty easy could be great.

If not possible, can i create such a thing and do a PR

Thnx

Unit tests for `FilterablePlugin`

I think before I continue work on PR #12 we should consider adding unit tests for FilterablePlugin. If you agree, I will submit a separate PR for this.

Possible inconstancies in operator inversion

While working on a PR for issue #8 if found what I believe are inconstancies in the way some comparison operators are inverted. For example: >= inverts to <=, I posit it should invert to <. The way I see it >= is inclusive of the value its comparing, therefore the inverted operator should not, hence < and not <= (which does).

The following should be corrected:

Operator Currently Inverts to Should invert to
>= <= <
> < <=
<= >= >
< > >=

If you agree I will submit a PR correcting this.

Add support for 'is:' operator

Add support for querying boolean queries using the is:xxx syntax. I propose something like the following:

var Filterable = require('filterable').Filterable;
var filterable = new Filterable({
  ...
  fields: {
    published: {
      type: Boolean
    },
    admin: {
      type: Boolean,
      alias: 'isAdmin'
    },
    gender: {
      type: String
    },
    male: {
      type: Boolean,
      query: 'gender:male'
    },
    female: {
      type: Boolean,
      query: 'gender:female'
    },
    age: {
      type: Number
    },
    minor: {
      type: Boolean,
      query: 'age:<18'
    },
  },
  ...
});

And .query() would yield:

filterable.query('is:published', function(err, query) {
    /*
    query.toMongo() == {
        "published": true
    }
    */
});

filterable.query("is:admin", function(err, query) {
    /*
    query.toMongo() == {
        "isAdmin": true
    }
    */
});

filterable.query('is:male', function(err, query) {
    /*
    query.toMongo() == {
        "gender": "male"
    }
    */
});

filterable.query('is:female', function(err, query) {
    /*
    query.toMongo() == {
        "gender": "female"
    }
    */
});

filterable.query('is:minor', function(err, query) {
    /*
    query.toMongo() == {
        "age": { "$lt": 18 }
    }
    */
});

The above is by no means an exhaustive description. If you're amenable to include this feature I would be willing to work on a PR.


This is my progress so far:

  • refactor code to split groups into a reusable function
  • implement "is:" operator in Query class
  • add unit tests
  • implement "is:" operator in FitlerablePlugin().
  • update README

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.