# microcms-filter-query

Latest version **0.3.3** (published 2022-04-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install microcms-filter-query
pnpm add microcms-filter-query
yarn add microcms-filter-query
bun add microcms-filter-query
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2022-04-10 |
| First published | 2022-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | hanetsuki <me@tsuki-lab.net> |
| Maintainers | tsuki-lab |
| Keywords | microcms |

## Links

- npm: https://www.npmjs.com/package/microcms-filter-query
- Repository: https://github.com/tsuki-lab/microcms-filter-query
- Homepage: https://github.com/tsuki-lab/microcms-filter-query#readme
- Issues: https://github.com/tsuki-lab/microcms-filter-query/issues
- npm.io page: https://npm.io/package/microcms-filter-query

## Dependencies (1)

- [type-fest](https://npm.io/package/type-fest.md) ^2.12.2

## Recent versions

- 0.3.3 (latest) — 2022-04-10
- 0.3.1 — 2022-04-06
- 0.3.0 — 2022-04-06
- 0.2.3 — 2022-04-04
- 0.2.2 — 2022-04-03
- 0.2.1 — 2022-04-03
- 0.2.0 — 2022-04-03
- 0.1.0 — 2022-04-02

## README

# microcms-filter-query

[microcms](https://microcms.io/)のリスト API の get クエリ、`filter`の条件文の作成補助ツール

## Installed

```bash
npm i microcms-filter-query
# or
yarn add microcms-filter-query
```

## Usage

basic usage.

```js
const { MicroCMSFilterQuery } = require('microcms-filter-query') // CommonJS
import { MicroCMSFilterQuery } from 'microcms-filter-query' //ES6

// gender[equals]female
const filterQuery = new MicroCMSFilterQuery()
  .equals('gender', 'female')
  .$execute()

// Get request to microcms
axios.get('https://{SERVICE_ID}.microcms.io/api/v1/{END_POINT}', {
  headers: {
    'X-MICROCMS-API-KEY': `{API_KEY}`,
  },
  params: {
    filters: filterQuery,
  },
})
```

usage for TypeScript.

```ts
import { MicroCMSFilterQuery } from 'microcms-filter-query'

type Avatar = {
  name: string
  gender: 'female' | 'male' | 'other'
}

// gender[equals]female
const filterQuery = new MicroCMSFilterQuery<Avatar & MicroCMSListContent>()
  .equals('gender', 'female') // argument is type safe
  .$execute()

// Get request to microcms
axios.get<MicroCMSListResponse<Avatar>>(
  'https://{SERVICE_ID}.microcms.io/api/v1/{END_POINT}',
  {
    headers: {
      'X-MICROCMS-API-KEY': `{API_KEY}`,
    },
    params: {
      filters: filterQuery,
    },
  }
)
```

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