Core
API v2.x
2

# hsetnx

Sets a field and its value in a hash, only if the field does not already exist.

[Redis documentation]


# Query Syntax

# HTTP

Copied to clipboard!
URL: http://kuzzle:7512/ms/_hsetnx/<_id>
Method: POST
Body:
Copied to clipboard!
{
  "field": "<field name>",
  "value": "<field value>"
}

# Other protocols

Copied to clipboard!
{
  "controller": "ms",
  "action": "hsetnx",
  "_id": "<key>",
  "body": {
    "field": "<field name>",
    "value": "<field value>"
  }
}

# Arguments

  • _id: hash key identifier

# Body properties

  • field: new hash field name
  • value: hash field value

# Response

Returns either 0 (command failed), or 1 (command succeeded).

Copied to clipboard!
{
  "requestId": "<unique request identifier>",
  "status": 200,
  "error": null,
  "controller": "ms",
  "action": "hsetnx",
  "collection": null,
  "index": null,
  "result": 1
}