MCPcopy Create free account
hub / github.com/distributedio/titan / HGet

Function HGet

command/hashes.go:77–96  ·  view source on GitHub ↗

HGet returns the value associated with field in the hash stored at key

(ctx *Context, txn *db.Transaction)

Source from the content-addressed store, hash-verified

75
76// HGet returns the value associated with field in the hash stored at key
77func HGet(ctx *Context, txn *db.Transaction) (OnCommit, error) {
78 key := []byte(ctx.Args[0])
79 field := []byte(ctx.Args[1])
80
81 hash, err := txn.Hash(key)
82 if err != nil {
83 if err == db.ErrTypeMismatch {
84 return nil, ErrTypeMismatch
85 }
86 return nil, errors.New("ERR " + err.Error())
87 }
88 val, err := hash.HGet(field)
89 if err != nil {
90 return nil, errors.New("ERR " + err.Error())
91 }
92 if val == nil {
93 return NullBulkString(ctx.Out), nil
94 }
95 return BulkString(ctx.Out, string(val)), nil
96}
97
98// HGetAll returns all fields and values of the hash stored at key
99func HGetAll(ctx *Context, txn *db.Transaction) (OnCommit, error) {

Callers

nothing calls this directly

Calls 5

NullBulkStringFunction · 0.85
BulkStringFunction · 0.85
HashMethod · 0.80
HGetMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected