# @windingtree/sdk-db

> Databases for the WindingTree market protocol

Latest version **1.3.3** (published 2024-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @windingtree/sdk-db
pnpm add @windingtree/sdk-db
yarn add @windingtree/sdk-db
bun add @windingtree/sdk-db
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.3 |
| Published | 2024-03-11 |
| First published | 2023-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 99.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Kostiantyn Smyrnov |
| Maintainers | kostysh, kvakes, tomashq |

## Links

- npm: https://www.npmjs.com/package/@windingtree/sdk-db
- Repository: https://github.com/windingtree/sdk.git#readme
- Homepage: https://github.com/windingtree/sdk/tree/readme#readme
- Issues: https://github.com/windingtree/sdk/issues
- npm.io page: https://npm.io/package/@windingtree/sdk-db

## Dependencies (6)

- [zod](https://npm.io/package/zod.md) ^3.22.4
- [viem](https://npm.io/package/viem.md) ^1.19.13
- [bcrypt-ts](https://npm.io/package/bcrypt-ts.md) ^4.0.0
- [@windingtree/sdk-types](https://npm.io/package/@windingtree/sdk-types.md) 1.1.4
- [@windingtree/sdk-logger](https://npm.io/package/@windingtree/sdk-logger.md) 1.1.4
- [@windingtree/sdk-storage](https://npm.io/package/@windingtree/sdk-storage.md) 1.5.0

## Recent versions

- 1.3.3 (latest) — 2024-03-11
- 1.2.6-beta.0 (beta) — 2024-01-17
- 1.3.2 — 2024-02-19
- 1.3.1 — 2024-02-19
- 1.3.0 — 2024-02-16
- 1.2.8 — 2024-02-12
- 1.2.7 — 2024-01-26
- 1.2.6 — 2024-01-17
- 1.2.5 — 2023-12-22
- 1.2.4 — 2023-12-11
- 1.2.3 — 2023-11-29
- 1.2.2 — 2023-10-31
- 1.2.1 — 2023-10-31
- 1.2.0 — 2023-10-25
- 1.2.0-beta.1 — 2023-10-25
- … 6 more at https://npm.io/package/@windingtree/sdk-db/versions

## README

# @windingtree/sdk-db

This package provides convenient abstraction and interaction with storage for the Winding Tree SDK. It includes functionalities for managing users and deals data in a secure and effective way. The package uses bcrypt hashing for password management and offers utilities for pagination.

## Installation

```bash
pnpm i @windingtree/sdk-db
```

## Key Concepts

- `UsersDb`: Provides methods for adding, getting, setting, and deleting users in the database. It also includes a method for comparing passwords.
- `DealsDb`: Provides methods for adding, getting, and retrieving all deals in the database.
- Both `UsersDb` and `DealsDb` require a storage instance and prefix for their constructor, which are used to manage their data in a common storage solution.
- Passwords in `UsersDb` are hashed using `bcrypt-ts`. This ensures that even if the user data were compromised, the passwords would still be safe.
- Pagination is supported in `DealsDb` for fetching multiple deals.

## Usage

```typescript
import { UsersDb, DealsDb } from '@windingtree/sdk-db';
import { memoryStorage } from '@windingtree/sdk-storage'; // localStorage, etc

const storageInitializer =
  memoryStorage.createInitializer(/* storage configuration */);
const prefix = 'winding_tree';

// Instantiate UsersDb
const usersDb = new UsersDb({ storage: await storageInitializer(), prefix });

// Use methods to interact with the users database
usersDb.add(/* parameters */);
usersDb.get(/* parameters */);
// and other methods...

// Instantiate DealsDb
const dealsDb = new DealsDb({ storage: await storageInitializer(), prefix });

// Use methods to interact with the deals database
dealsDb.set(/* parameters */);
dealsDb.get(/* parameters */);
dealsDb.getAll(/* parameters */);
```

## Documentation

For full documentation and examples, visit [windingtree.github.io/sdk](https://windingtree.github.io/sdk)

## Testing

```bash
pnpm test
```

## Contributing

[Contribution guidelines](https://windingtree.github.io/sdk/#/docs/contribution)

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