2.5.1 • Published 10 days ago

@hongfangze/database v2.5.1

Weekly downloads
-
License
MIT
Repository
-
Last release
10 days ago

@hongfangze/database 数据库操作类

介绍

支持Mysql、Postgresql、Redis

Redis使用

 const Redis = CreateRedis({
    host: "",
    password: "",
    db: 1,
  });
  await Redis.set("a", "1");
  await Redis.set("b", "2", 10);
  let res = await Redis.get("a");
  console.log("get", res);
  res = await Redis.ttl("a");
  console.log("ttl", res);
  res = await Redis.exists("a");
  console.log("exists", res);
  res = await Redis.exists("c");
  console.log("exists", res);
  res = await Redis.exists("c");
  console.log("exists", res);
  await Redis.del("a");
  await Redis.set("hello word", "2", 10);
  res = await Redis.keys();
  console.log("keys", res);
  res = await Redis.keys("h*");
  //  res = await Redis.keys("h?llow word");
  //  res = await Redis.keys("h[eo]llow word");
  console.log("keys", res);

  await Redis.rpush("list", "1");
  await Redis.rpush("list", "2");
  await Redis.rpush("list", "3");
  while (true) {
    let list = await Redis.lpop("list");
    if (!list) {
      break;
    }
    console.log("list", list);
    await sleep(1000);
  }

const taskInstance = new Task();
  const params = new Array(100).fill('');
  taskInstance.on("process", (index, err, result: any) => {
    console.log(`第${index}个任务已经完成,返回值:`, result);
  });
  taskInstance.on("end", (results) => {
    console.log("所有任务完成,返回值:", results);
  });
  await taskInstance.start(getAutoNumber, params, 20);

async function getAutoNumber() {
  const redis = CreateRedis({
    password: ""
  });
  let number = await redis.getAutoNumber("ORDER", "YYYYMMDD", 6, "END");
  return number;
}

版本迭代记录

2024-04-28 v2.5.1

  • 取编号功能Bug修复,命名处理

2024-04-28 v2.5.0

  • 取编号功能支持自定义日期格式

2024-04-15 v2.4.0

  • Redis增加锁获取编号功能

2024-03-14 v2.3.0

  • 增加Redis的支持
2.5.1

10 days ago

2.5.0

11 days ago

2.4.0

24 days ago

2.3.0

2 months ago

2.2.1

4 months ago

2.2.0

4 months ago

2.1.5

6 months ago

2.1.4

8 months ago

2.1.3

8 months ago

2.1.2

9 months ago

2.1.1

9 months ago

2.1.0

9 months ago

2.0.0

9 months ago

1.2.0

9 months ago

1.1.0

9 months ago

1.0.0

9 months ago

0.0.4

9 months ago

0.0.1

9 months ago