1.3.3 • Published 2 months ago

@windingtree/sdk-db v1.3.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@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

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

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

Testing

pnpm test

Contributing

Contribution guidelines

1.3.3

2 months ago

1.3.2

3 months ago

1.3.1

3 months ago

1.3.0

3 months ago

1.2.8

3 months ago

1.2.7

3 months ago

1.2.6-beta.0

4 months ago

1.2.6

4 months ago

1.2.5

5 months ago

1.2.4

5 months ago

1.2.3

5 months ago

1.2.2

6 months ago

1.2.1

6 months ago

1.2.0

7 months ago

1.2.0-beta.1

7 months ago

1.2.0-beta.0

9 months ago

1.1.0

10 months ago

1.1.0-beta.3

10 months ago

1.1.0-beta.2

10 months ago

1.1.0-beta.1

10 months ago

1.1.0-beta.0

10 months ago