0.0.8 • Published 4 years ago

ioredis-type v0.0.8

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

ioredis-type

redis type orm

Installation

npm install ioredis-type

Usage

client

const Redis = require('ioredis-type');

const redis = new Redis({
  // host: '127.0.0.1',
  // password: '',
  // port: 6379,
  // db: 0,
});

Number

async function main() {
  const number = redis.root.Number('number');

  await number.set(10);
  
  await number.get(); // 10
  
  await number.inc(-1); // 9
}

main().finally(() => redis.close())

test example

List

async function main() {
  const list = redis.root.List('list');

  await list.push('a', 'b', 'c', 'd');
  
  await list.pop(2);
  
  await list.slice(1);
  await list.slice(1, 3, true);
  await list.slice(1, undefined, true);
  
  await list.index(-4);
}

main().finally(() => redis.close())

test example

ZSet

async function main() {
  const zset = redis.root.ZSet('zset');

  await zset.push('a', 'b', 'c', 'd');
  
  await zset.set('a', 1);
  await zset.set('c', 3);
  await zset.set('b', 2);
  await zset.set('d', 3);
  
  await zset.slice(1);
  await zset.slice(1, 3, true);
  await zset.slice(1, undefined, true);
  
  await zset.index(-4);
}

main().finally(() => redis.close())

test example

Table

async function main() {
  const table = redis.root.Table('table');

  await table.insert({
      t: true,
      f: false,
      u: undefined,
      n: null,
      s: '',
      i: 0,
      a: ['A', 'B,C'],
    });
  
  await table.select();
}

main().finally(() => redis.close())

test example

Dir

async function main() {
  const dirA = redis.root.Dir('A');
  const dirAa = dirA.Dir('a');
  
  await dirA.Number('num').set(10);
  await dirAa.Number('num').set(100);
}

main().finally(() => redis.close())

test example

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.0.0

4 years ago