Skip to content

Commit

Permalink
fix: deal
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Pomar committed Apr 17, 2024
1 parent fb375f1 commit 289b52a
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,32 @@
</a>
</p>

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:
Expand Down Expand Up @@ -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 | `{<db_field>:{$eq:<value>}` |
| `!:` | Not equal | `{<db_field>:{$ne:<value>}` |
| Operator | Description | MongoDB |
| -------- | ----------- | ---------------------------- |
| `:` | Equal | `{<db_field>:{$eq:<value>}}` |
| `!:` | Not equal | `{<db_field>:{$ne:<value>}}` |

## About

Expand Down

0 comments on commit 289b52a

Please sign in to comment.