@pi-r/redis 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/client/index.js +8 -9
  2. package/package.json +1 -1
package/client/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DB_SOURCE_TYPE = exports.DB_SOURCE_CLIENT = exports.checkTimeout = exports.executeBatchQuery = exports.executeQuery = exports.setCredential = void 0;
4
+ const redis = require("redis");
4
5
  const util_1 = require("@e-mc/db/util");
5
6
  const types_1 = require("@e-mc/types");
6
7
  const Db = require("@e-mc/db");
@@ -107,7 +108,6 @@ async function setCredential(item) {
107
108
  }
108
109
  const poolKey = getPoolKey(client);
109
110
  if (!(pool = POOL_STATE[poolKey]) || pool.closed) {
110
- const db = require("redis");
111
111
  const config = this.getPoolConfig("redis", password);
112
112
  const poolOptions = client.isolationPoolOptions || (client.isolationPoolOptions = {});
113
113
  if (config) {
@@ -129,9 +129,9 @@ async function setCredential(item) {
129
129
  }
130
130
  }
131
131
  try {
132
- const redis = new RedisPool(await getClient(db, client, poolKey), poolKey, username && password ? { username, password } : undefined).add(item);
133
- redis.parent = POOL_STATE;
134
- redis.success = 1;
132
+ const target = new RedisPool(await getClient(redis, client, poolKey), poolKey, username && password ? { username, password } : undefined).add(item);
133
+ target.parent = POOL_STATE;
134
+ target.success = 1;
135
135
  }
136
136
  catch {
137
137
  item.usePool = false;
@@ -154,7 +154,6 @@ async function executeBatchQuery(batch, options = '', outResult) {
154
154
  if (length === 0) {
155
155
  return [];
156
156
  }
157
- const db = require("redis");
158
157
  let parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss;
159
158
  if ((0, types_1.isPlainObject)(options)) {
160
159
  ({ parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
@@ -196,7 +195,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
196
195
  (credential.isolationPoolOptions || (credential.isolationPoolOptions = {})).max = size;
197
196
  }
198
197
  }
199
- clients.push(client = await getClient(db, credential));
198
+ clients.push(client = await getClient(redis, credential));
200
199
  }
201
200
  if (connectOnce) {
202
201
  redisClient = client;
@@ -231,7 +230,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
231
230
  const targetObject = typeof checkObject === 'string' ? this.hasCoerce("redis", 'options', uuidKey) && (0, types_1.asFunction)(checkObject) : checkObject;
232
231
  const renewCache = ignoreCache === 0;
233
232
  const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
234
- const command = (0, types_1.isPlainObject)(clientOptions.command) ? db.commandOptions(clientOptions.command) : null;
233
+ const command = (0, types_1.isPlainObject)(clientOptions.command) ? redis.commandOptions(clientOptions.command) : null;
235
234
  let queryString = '', rows;
236
235
  if (caching && ignoreCache !== true || ignoreCache === false || ignoreCache === 1 || renewCache) {
237
236
  if ((0, types_1.isObject)(search)) {
@@ -293,7 +292,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
293
292
  }
294
293
  const failKey = () => failed((0, types_1.errorMessage)(f, "Invalid key", Db.asString(k) || "Unknown"));
295
294
  const failValue = () => failed((0, types_1.errorMessage)(f, "Invalid value", Db.asString(v) || "Unknown"));
296
- const commandSet = (0, types_1.isPlainObject)(setOptions.command) && db.commandOptions(setOptions.command);
295
+ const commandSet = (0, types_1.isPlainObject)(setOptions.command) && redis.commandOptions(setOptions.command);
297
296
  let pending;
298
297
  if ((f = f.toUpperCase()) === 'JSON') {
299
298
  if (typeof k !== 'string') {
@@ -454,7 +453,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
454
453
  try {
455
454
  if (target === search) {
456
455
  const reply = await (command ? client.ft.search(command, index || idx, query, clientOptions.search) : client.ft.search(index || idx, query, clientOptions.search));
457
- rows = reply.documents.map(doc => (doc.value['__id__'] = doc.id) && doc.value);
456
+ rows = reply.documents.map(doc => (doc.value.__id__ = doc.id) && doc.value);
458
457
  }
459
458
  else {
460
459
  ({ results: rows } = await (command ? client.ft.aggregate(command, index || idx, query, clientOptions.aggregate) : client.ft.aggregate(index || idx, query, clientOptions.aggregate)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/redis",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Redis client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",