ArgumentTransformer for zadd
See original GitHub issueDoc for zadd: https://redis.io/commands/zadd
Hello,
The zadd command can accept endless score member [score member ...]
. May I have a default ArgumentTransformer for zadd? I can create a PR for that.
My code:
function convertFilpObjectToArray (obj) {
var result = []
for (var key in obj) {
result.push(obj[key], key)
}
return result
}
Redis.Command.setArgumentTransformer('zadd', args => {
if (args.length > 1) {
let last = args.pop()
if (typeof last === 'object' && last !== null) {
args.concat(convertFilpObjectToArray(last))
} else args.push(last)
}
return args
})
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
ZADD
Adds all the specified members with the specified scores to the sorted set stored at key . It is possible to specify multiple...
Read more >Performance-focused & full-featured Redis client for Node.js
A robust, performance-focused and full-featured Redis client for Node.js. Supports Redis >= 2.6.12 and (Node.js >= 6). Completely compatible with Redis 6.x.
Read more >RedisAPI (Vert.x Stack - Docs 4.2.7 API) - Eclipse Vert.x
RedisAPI · zadd(List<String> args, Handler<AsyncResult<Response>> handler). Redis command zadd. RedisAPI · zcard(String arg0). Redis command zcard.
Read more >Command (Vertx Javadocs 4.0.3.GA API)
static Command · ZADD. static Command · ZCARD. static Command · ZCOUNT. static Command · ZINCRBY. static Command · ZINTERSTORE. static Command ·...
Read more >github.com-luin-ioredis_-_2022-06-25_07-27-55
There are two typesof transformers, argument transformer and reply transformer: ```javascriptconst Redis = require("ioredis");.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m aware of this fact. It’s just not straightforward compared with the transformer of
hmset
for the hash key, which itself is an object.Anyway, I’d like to accept a PR for that, as long as the transformer keeps the same format with
hmset
that only takes effect when the argument length is 2 and supports both Map and plain object.It’s a little confused whether
score
should be the key or the value of an object (at least more confused thanmset
for a hash key).Since ioredis flattens arguments, the following form is supported:
Given that I don’t think the transformer is necessary.