Skip to content

Commit 0b9090d

Browse files
DOC-4942 SETNX command details
1 parent 05d7ef8 commit 0b9090d

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

content/develop/clients/nodejs/migration.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ each feature.
4545
| [Command argument handling](#command-argument-handling) | Argument objects flattened and items passed directly | Argument objects parsed to generate correct argument list |
4646
| [Asynchronous command result handling](#async-result) | Callbacks and Promises | Promises only |
4747

48-
### Specific commands
48+
### Techniques
4949

5050
| Feature | `ioredis` | `node-redis` |
5151
| :-- | :-- | :-- |
52+
| [Pipelining](#pipelining) | Automatic, or with `pipeline()` command | Automatic, or with `multi()` command |
5253

54+
### Specific commands
5355

54-
### Techniques
55-
56-
| Feature | `ioredis` | `node-redis` |
56+
| Command | `ioredis` | `node-redis` |
5757
| :-- | :-- | :-- |
58-
| [Pipelining](#pipelining) | Automatic, or with `pipeline()` command | Automatic, or with `multi()` command |
58+
| [`SETNX`](#setnx-command) | Supported explicitly | Supported as an option for `SET` |
5959

6060
## Details
6161

@@ -229,3 +229,20 @@ redis.multi()
229229
// Handle errors.
230230
});
231231
```
232+
233+
### `SETNX` command
234+
235+
`ioredis` implements the [`SETNX`]({{< relref "/commands/setnx" >}})
236+
command with an explicit method:
237+
238+
```js
239+
client.setnx("bike:1", "bike");
240+
```
241+
242+
`node-redis` doesn't provide a `SETNX` method but implements the same
243+
functionality with the `NX` option to the [`SET`]({{< relref "/commands/set" >}})
244+
command:
245+
246+
```js
247+
await client.set("bike:1", "bike", {'NX': true});
248+
```

0 commit comments

Comments
 (0)