# qman

> Ultra lightweight query manager

Latest version **0.2.10** (published 2024-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install qman
pnpm add qman
yarn add qman
bun add qman
```

## 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.2.10 |
| Published | 2024-01-25 |
| First published | 2023-08-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 42.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Samuel Hulla |
| Maintainers | samuelhulla |
| Keywords | qman, fetch, fetch-manager, request, cache, swr, query, tanstack query, react query, axios, hooks, react, vanilla, react-query, nanoquery, firebase, react-native-firebase, firestore, auth |

## Links

- npm: https://www.npmjs.com/package/qman
- Repository: https://github.com/samuelhulla/qman
- Homepage: https://hulla.dev/qman
- Issues: https://github.com/samuelhulla/qman/issues
- npm.io page: https://npm.io/package/qman

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 0.2.10 (latest) — 2024-01-25
- 0.2.9 — 2024-01-23
- 0.2.8 — 2024-01-23
- 0.2.7 — 2024-01-22
- 0.2.6 — 2024-01-19
- 0.2.5 — 2024-01-19
- 0.2.4 — 2024-01-02
- 0.2.3 — 2024-01-02
- 0.2.2 — 2024-01-02
- 0.2.1 — 2024-01-02
- 0.2.0 — 2024-01-02
- 0.1.2 — 2023-09-06
- 0.1.1 — 2023-09-05
- 0.1.0 — 2023-09-05
- 0.0.27 — 2023-08-25
- … 27 more at https://npm.io/package/qman/versions

## README

# Ultra lightweight `q`uery `man`ager

- super small bundle size 📦
- manages deterministic query keys and invocations 🛠️
- enhances type safety of existing fetching packages 🧪
- organizes fetching structure into schemas 🫐
- fully tree shake-able 🌴

##  Usage
```ts
import { query, schema } from 'qman'
import { use } from 'qman/swr' // or qman/query

// Specifies your getters, can be api route, db handlers, anything that returns a promise
const getAllUsers = () => fetch('your.api/users/')
const getUserById = (id: string) => fetch(`your.api/users/${id}`)

// Specifies a schema that organizes your api, declare multiple schemas based on category
export const users = schema(
  'users',
  query('allUsers', getAllUsers, use), 
  query('byId', getUserById, use),
  query('somePromise', directDBPromiseFn) // note we don't have to use swr/query adapters here
)

// Later in code (usually in different file) use your schema.
users.get('allUsers', [])
users.get('byId', ['exampleId123']) // You get full type-safety here with exact argument names i.e. `[id: string]`
```

This also ensures your query keys are always unique even if different schemas have same queries.
i.e. you can have a schema called `users` and `posts` which both ship `byId` query. You can be sure and safe that even if you mutate / revalidate, it will stay within the schema boundaries and will get type safety according to schema definitions.



## Advanced usage
Adds support for advanced query usage, such as
- firebase
- subscriptions
- infinite and paginated queries
- mutations
- and more

> documentation will come with beta release, will expand on these topics.

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