Reputation: 2084
all
I am studying node_redis, in examples/simple.js, there is the following code:
1 client.hset("hash key", "hashtest 1", "some value", redis.print);
2 client.hset(["hash key", "hashtest 2", "some other value"], redis.print);
3 client.hkeys("hash key", function (err, replies) {
4 console.log(replies.length + " replies:");
5 replies.forEach(function (reply, i) {
...
I am confused that :
why line 3 has two parameters "(err, replies)" , does the designer define how many parameters?
or would you like to guide me what book or other something I should read to understand them? Thank you in advance!
BEST REGARDS
PengCZ
Upvotes: 0
Views: 235
Reputation: 698
function (error, data..) is de-facto standard for arguments of callbacks in node.js.
If operation completes successfully, error is null, and replies is array with hash keys. If there was error, error contains details and replies are not filled.
Is that what you are asking about?
Upvotes: 2