# sein-redis

> A npm module that provides secondary indexing for Redis",

Latest version **1.0.2** (published 2019-02-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install sein-redis
pnpm add sein-redis
yarn add sein-redis
bun add sein-redis
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-02-24 |
| First published | 2019-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Maintainers | admirkadriu |
| Keywords | redis |

## Links

- npm: https://www.npmjs.com/package/sein-redis
- Repository: https://github.com/admirkadriu/sein-redis
- Homepage: https://github.com/admirkadriu/sein-redis#readme
- Issues: https://github.com/admirkadriu/sein-redis/issues
- npm.io page: https://npm.io/package/sein-redis

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^4.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.11

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2019-02-24
- 1.0.1 — 2019-01-17

## README

# sein-redis
Secondary indexing with Redis


# Quick Start

## Install
```shell
$ npm install sein-redis
```

## Usage Example
```javascript
const Redis = require('ioredis');
const seinRedis = require('sein-redis');

const redis = new Redis();

seinRedis.setClient(redis);
seinRedis.setPrefix('example');
  
class UserModel extends seinRedis.Model {
  constructor() {
    super();
    this.modelName = 'User';

    this.setDefinitions([
      {
        name: 'id',
        primaryKey: true,
      },
      {
        name: 'email',
        uniqueIndex: true,
      },
      {
        name: 'typeId',
        index: true,
      },
    ]);
  }

  getByEmail(email) {
    return this.getByUniqueIndex({ email }, true);
  }

  getByType(typeId) {
    return this.getByIndex({ typeId }, true);
  }
}

const isSet = await userModel.set({
                      id: 'd982398j2398u',
                      name: 'Test User',
                      email: 'testuser@tests.com',
                      typeId: 1,
                    });

let user = await userModel.get('d982398j2398u');

user = await userModel.getByEmail('testuser@tests.com');

const users = await userModel.getByType(1);
```

# Licence
MIT

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