# @neferett/nedis

Latest version **1.2.0** (published 2020-05-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install @neferett/nedis
pnpm add @neferett/nedis
yarn add @neferett/nedis
bun add @neferett/nedis
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2020-05-26 |
| First published | 2020-05-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 17.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | neferett |

## Links

- npm: https://www.npmjs.com/package/@neferett/nedis
- Repository: https://github.com/jordanbonaldi/DatabaseCollector
- Homepage: https://github.com/jordanbonaldi/DatabaseCollector#readme
- Issues: https://github.com/jordanbonaldi/DatabaseCollector/issues
- npm.io page: https://npm.io/package/@neferett/nedis

## Dependencies (3)

- [redis](https://npm.io/package/redis.md) ^3.0.2
- [@types/node](https://npm.io/package/@types/node.md) ^13.9.1
- [npm-auto-version](https://npm.io/package/npm-auto-version.md) ^1.0.0

## Recent versions

- 1.2.0 (latest) — 2020-05-26
- 1.1.18 — 2020-05-26

## README

# RedisAPI NodeJS


<p align="center">
 <img src="https://img.shields.io/npm/dm/@neferett/nedis.svg" alt="Downloads"></a>
 <a href="https://www.npmjs.com/package/@neferett/nedis"><img src="https://img.shields.io/npm/v/@neferett/nedis.svg" alt="Version"></a>
 <a href="https://github.com/jordanbonaldi/Nedis/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License"></a>
</p>
	

## Installation

`npm install @neferett/nedis`

```typescript
 new RedisDatabase(<host>, <password>).connect()
```

## How to use it

First you have to create a Model class extending the abstract RedisModel as follow:
   ```typescript
 export interface CategoryInterface {  
	  assets : string[],  
	  messageID : string,  
	  name ?: string  
}  
	  
export default new class CategoryModel extends RedisModel {  
	  constructor() {
		  // First arguments is the database number
		  // Second arguments is the folder folder name
		  super(2, 'categories');  
	 }  
}
```

Once your model is created and your database connected you can do as follow:
```typescript
 CategoryModel.create<CategoryInterface>('6', {  
  assets: ["BTCUSD"],  
  messageID: "189027633",  
  name: "Bitcoin"  
});

CategoryModel.read<CategoryInterface>('6').then((category: CategoryInterface) => {});

CategoryModel.update<CategoryInterface>('6', {  
  assets: ["BTCUSD", "ETHUSD"],  
  messageID: "189027633",  
  name: "Bitcoin"  
}).then((category: CategoryInterface) => {});

CategoryModel.getAll<CategoryInterface>().then((categories: {value: string, data: CategoryInterface}[]) => {  
  // Do whatever you want  
});

CategoryModel.delete('6');

CategoryModel.read<CategoryInterface>('6').then((category: CategoryInterface) =>   
 CategoryModel.update<CategoryInterface>('6', {  
  ...category,  
  assets: ["ETHUSD"]  
 }));
```

## Models Methods

```typescript
/* Data ID to create with the interface/class to push */
create<T>(id: string, data: T): Promise<T>;  

/* Data ID to read and return in promise */
read<T>(id: string): Promise<T>;  

/* Data ID and new Data to push */
update<T>(id: string, data: T): Promise<T>;  
  
/* Data ID to delete*/  
delete(id: string): Promise<boolean>;  
  
/* All Data inside Models to return */
getAll<T>(): Promise<{value: string, data: T[]}[]>;

```

## License

Licensed under MIT

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