2.0.1 • Published 8 years ago

filterable v2.0.1

Weekly downloads
44
License
Apache-2.0
Repository
github
Last release
8 years ago

Filterable

Build Status NPM version

Filterable is a Node.JS module to parse GitHub-like search queries, for example: cats stars:>10. It can generates MongoDB or Elasticsearch queries.

This module is perfect to integrates complex search (like GitHub) into your application. It integrates perfectly with MongoDB but can also easily be adapted to other databases.

Queries

TypeExample
Query for tagscat
Query for multiple tagscat dog, "Hello World"
Exclude results containing a certain wordcat NOT dog
Query for equalityusername:Samypesse, name:"Samy Pesse"
Query for values greater than another valuestars:>10, stars:>=10
Query for values less than another valuestars:<100, stars:<=100
Mix query for tags and conditioncat stars:>10 stars:<100
Filter qualifiers based on exclusioncats stars:>10 NOT language:javascript

How to use it?

Install it using:

$ npm install filterable

Parse a query string:

var filterable = require("filterable");

var query = filterable.Query('cats stars:>10')
    .parse();

Output query for a database:

var mongQuery = query.toMongo();

Filter and customize queries using QueryBuilder:

var builder = filterable.QueryBuilder({
    // Field using when quering with text
    textField: 'description'
});

// Define mapping, by default all fields are accepted and piped as string
builder.field('stars', {
    type: Number
});

// Reject a field
builder.reject('email');


// Parse queries (return a Query object)
var q1 = builder.parse('Hello world')
var q2 = builder.parse('cats stars:>10');
2.0.1

8 years ago

2.0.0

8 years ago

1.0.0

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago

0.0.0

9 years ago