HGet returns the value associated with field in the hash stored at key
(ctx *Context, txn *db.Transaction)
| 75 | |
| 76 | // HGet returns the value associated with field in the hash stored at key |
| 77 | func 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 |
| 99 | func HGetAll(ctx *Context, txn *db.Transaction) (OnCommit, error) { |
nothing calls this directly
no test coverage detected