From 289b52ad61f1cf553b4d3335613599ee756a6fa3 Mon Sep 17 00:00:00 2001 From: Marc Pomar Date: Wed, 17 Apr 2024 12:51:04 +0200 Subject: [PATCH] fix: deal --- README.md | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) 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 | `{:{$eq:}` | -| `!:` | Not equal | `{:{$ne:}` | +| Operator | Description | MongoDB | +| -------- | ----------- | ---------------------------- | +| `:` | Equal | `{:{$eq:}}` | +| `!:` | Not equal | `{:{$ne:}}` | ## About