<commit_before># query

> Declarative and expressive database queries.

## Idea

Nested queries are awful to write in most programing languages.
This query builder aims very specific needs. Imagine a case where
someone has always to fetch a certain `document` in order to fetch another one.

We want to do this in a `declarative` way and also allow functional programing.
In all cases, `callback` or any other evaluation is prohibited.

## Examples

Query a document, populate all documents at path `users`, select the user level
and lookup levels by id, reduce than by level value.

```js
query()
  .use('groups')
  .find({id: 1})
  .populate('users')
  .select('users.level')
  .use('levels')
  .find({id: 'users.level'})
  .reduce((total, level) => total += level.val, 0)
```

Update nested document(s).

```js
query()
  .use('groups')
  .find()
  .populate('users')
  .use('users')
  .update({id: 'users.id'}, {role: 'USER'})<commit_msg>docs(setup): add setup<commit_after># query

> Declarative and expressive database queries.

## Idea

Nested queries are awful to write in most programing languages.
This query builder aims very specific needs. Imagine a case where
someone has always to fetch a certain `document` in order to fetch another one.

We want to do this in a `declarative` way and also allow functional programing.
In all cases, `callback` or any other evaluation is prohibited.

## Install

```bash
npm i -S netiam-query
```

## Adapter

```js
import adapter from 'netiam-adapter'

const connection = adapter({…})

query(connection)
  .use('groups')
  …
```

## Examples

Query a document, populate all documents at path `users`, select the user level
and lookup levels by id, reduce than by level value.

```js
query()
  .use('groups')
  .find({id: 1})
  .populate('users')
  .select('users.level')
  .use('levels')
  .find({id: 'users.level'})
  .reduce((total, level) => total += level.val, 0)
```

Update nested document(s).

```js
query()
  .use('groups')
  .find()
  .populate('users')
  .use('users')
  .update({id: 'users.id'}, {role: 'USER'})
{'fraction_non_alphanumeric': 0.13906325446644133, 'fraction_numerical': 0.001931434089811685, 'mean_word_length': 4.154228855721393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '999815', 'n_tokens_mistral': 667, 'n_tokens_neox': 640, 'n_words': 257}