Skip to main content

HSETNX

Syntax

HSETNX key field value [field value ...]

Module

hash

Categories

fast hash write

Description

Set hash field value only if the field does not exist.

Examples

Set hash field value:

db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
noOfUpdatedFields, err := db.HSetNX("key", map[string]string{"field1": "value1", "field2": "value2"})