diff --git a/README.md b/README.md index 98cd624..ec0025a 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,32 @@
-Syntax: +## Usage +Convert the following FaableQL query `status:published order:created` to a valid mongodb query. + +```js +const config = {...} +const fql = create_faableql(config) +const query = fql(`status:published type:article`) ``` -Query = FieldTerm { whitespace FieldTerm } -FieldTerm = name Operator value + +results in. + +```json +{ + "$and": [ + { "status": { "$eq": "published" } }, + { "type": { "$eq": "article" } } + ] +} ``` +Use cases: + +- As a cli flag. ie: `mycli --filter status:published` +- To filter results in a single query param. ie: `GET /publications?q=status:published` + ## Install With NPM: @@ -76,14 +95,21 @@ use `mongoose` to get results filtered by your query const docs = await Model.find(mongodb_query); ``` +## Syntax + +``` +Query = FieldTerm { whitespace FieldTerm } +FieldTerm = name Operator value +``` + ## Operators Avaliable operators -| Operator | Description | MongoDB | -| -------- | ----------- | --------------------------- | -| `:` | Equal | `{