GitXplorerGitXplorer
G

filterable

public
61 stars
8 forks
4 issues

Commits

List of commits on branch master.
Unverified
0d5addf56a850def3101ca4d2d23b0d42fe19851

spelling (#17)

ddiversen committed 8 years ago
Unverified
ac42ca0c913d46ba969be52954c2a5bf3859ec4d

Bump version to 2.0.1

SSamyPesse committed 9 years ago
Unverified
aabb9248fbb023b2634254ad9e30b9656725e199

Correctly escape on toString

SSamyPesse committed 9 years ago
Unverified
406c6605dc4e76290b3850e20b300f396ddea7bd

Bump version to 2.0.0

SSamyPesse committed 9 years ago
Unverified
5f4dca294b17263d3536c469491ceb7423303eb4

Convert as number when using number operators

SSamyPesse committed 9 years ago
Unverified
7ab0ffcd71966c1f8cc8a06314510053d4330965

Merge pull request #16 from GitbookIO/2.0.0

SSamyPesse committed 9 years ago

README

The README file for this repository.

Filterable

Build Status NPM version

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

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

Queries

Type Example
Query for tags cat
Query for multiple tags cat dog, "Hello World"
Exclude results containing a certain word cat NOT dog
Query for equality username:Samypesse, name:"Samy Pesse"
Query for values greater than another value stars:>10, stars:>=10
Query for values less than another value stars:<100, stars:<=100
Mix query for tags and condition cat stars:>10 stars:<100
Filter qualifiers based on exclusion cats 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');