# query-adapter

> Btime Query-adapter Package

Latest version **2.4.3** (published 2020-03-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install query-adapter
pnpm add query-adapter
yarn add query-adapter
bun add query-adapter
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.4.3 |
| Published | 2020-03-18 |
| First published | 2020-03-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.10.0 |
| Dependencies | 5 |
| Unpacked size | 36 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Btime |
| Maintainers | domene |

## Links

- npm: https://www.npmjs.com/package/query-adapter
- Repository: https://github.com/Btime/btime-utils-functions
- Homepage: https://github.com/Btime/query-adapter#readme
- Issues: https://github.com/Btime/query-adapter/issues
- npm.io page: https://npm.io/package/query-adapter

## Dependencies (5)

- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [@hapi/joi](https://npm.io/package/@hapi/joi.md) ^15.0.3
- [error-messages](https://npm.io/package/error-messages.md) github:Btime/error-messages#semver:^2
- [btime-utils-functions](https://npm.io/package/btime-utils-functions.md) github:Btime/btime-utils-functions#semver:^1
- [btime-company-permission](https://npm.io/package/btime-company-permission.md) github:Btime/btime-company-permission#semver:^1

## Recent versions

- 2.4.3 (latest) — 2020-03-18

## README

# Btime Query-Adapter Package

### Description

Query Adapter is an abstraction package made to format all regular endpoint usages to use query service.

The main purpose of it is to gather all `GET` endpoints, used when listing resources, into a specific and more generalist one.

**PS.: Only [`query`](https://github.com/Btime/query) service uses this adapter.**

Example:

```bash
# INPUT
GET /addresses?requestOptions={"fields":["id","name"]}

# OUTPUT
GET /queries?requestOptions={"entity":"address","options":{"fields":["id","name"]}}
```

### Usage

Install:

```bash
$ npm i Btime/query-adapter#semver:^1 -S
```

#### Example of Usage on Query Service

```js
const queryAdapter = require('query-adapter')

queryAdapter(params)
  .then(result => 'your code here')
  .catch(err => 'your code here')
```

Params must be an object as the below example:

```json
{
  "adapter": "Boolean",
  "credentials": "Object",
  "originalEntity": "String",
  "entity": "String"
}
```

#### Glossary

- `adapter`: It defines whether the adapter will be used;
- `credentials`: User's credentials;
- `originalEntity`: Entity to format payload;
- `entity`: It must be sended when originalEntity is `minicrud` or `export`;

### Package Dependency

- [Company Permission](https://github.com/Btime/btime-company-permission)
- [Utils Functions](https://github.com/Btime/btime-utils-functions)

### Pushing versions - SemVer

All pushes must come with a new tag. The tag usage must consider semantic versions.

`[major version: incompatible changes].[minor version: compatible with major].[patch version: bug fixes]`

Before pushing each version, type:

- For patch changes: `npm version patch`
- For minor changes: `npm version minor`
- For major changes: `npm version major`

---
_Source: https://npm.io/package/query-adapter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
