gitbookio / filterable Goto Github PK
View Code? Open in Web Editor NEWParse and convert GitHub-like search queries in Node.JS
License: Apache License 2.0
Parse and convert GitHub-like search queries in Node.JS
License: Apache License 2.0
Accept multi field as alias and convert it to an $or
of the condition.
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
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.
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 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:
Query
classFitlerablePlugin()
.Current GROUP_DELIMITER
regex does not support queries with escaped quotes inside:
label:"test \" test"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.