File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
content/develop/clients/nodejs Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ each feature.
43
43
| :-- | :-- | :-- |
44
44
| [ Command case] ( #command-case ) | Lowercase only (eg, ` hset ` ) | Uppercase or camel case (eg, ` HSET ` or ` hSet ` ) |
45
45
| [ Command argument handling] ( #command-argument-handling ) | Argument objects flattened and items passed directly | Argument objects parsed to generate correct argument list |
46
- | [ Asynchronous command result handling] ( #async-result ) | Callbacks and Promises | Promises only |
46
+ | [ Asynchronous command result handling] ( #async-result ) | Callbacks and Promises | Promises and Callbacks (via Legacy Mode) |
47
47
| [ Arbitrary command execution] ( #arbitrary-command-execution ) | Uses the ` call() ` method | Uses the ` sendCommand() ` method |
48
48
49
49
### Techniques
@@ -189,7 +189,22 @@ client.get('mykey').then(
189
189
` node-redis ` supports only ` Promise ` objects for results, so
190
190
you must always use a ` then() ` handler or the
191
191
[ ` await ` ] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await )
192
- operator to receive them.
192
+ operator to receive them, however callbacks are still supported via the legacy mode:
193
+
194
+ ``` js
195
+ // Promise
196
+ await client .set (' mykey' , ' myvalue' );
197
+
198
+ // Callback
199
+ const legacyClient = client .legacy ();
200
+ legacyClient .set (" mykey" , " myvalue" , (err , result ) => {
201
+ if (err) {
202
+ console .error (err);
203
+ } else {
204
+ console .log (result);
205
+ }
206
+ });
207
+ ```
193
208
194
209
### Arbitrary command execution
195
210
You can’t perform that action at this time.
0 commit comments