HGetAll returns all fields and values of the hash stored at key
(ctx *Context, txn *db.Transaction)
| 97 | |
| 98 | // HGetAll returns all fields and values of the hash stored at key |
| 99 | func HGetAll(ctx *Context, txn *db.Transaction) (OnCommit, error) { |
| 100 | key := []byte(ctx.Args[0]) |
| 101 | hash, err := txn.Hash(key) |
| 102 | if err != nil { |
| 103 | if err == db.ErrTypeMismatch { |
| 104 | return nil, ErrTypeMismatch |
| 105 | } |
| 106 | return nil, errors.New("ERR " + err.Error()) |
| 107 | } |
| 108 | fields, vals, err := hash.HGetAll() |
| 109 | if err != nil { |
| 110 | return nil, errors.New("ERR " + err.Error()) |
| 111 | } |
| 112 | |
| 113 | results := make([][]byte, len(fields)*2) |
| 114 | for i := range fields { |
| 115 | results[i*2] = fields[i] |
| 116 | results[i*2+1] = vals[i] |
| 117 | } |
| 118 | |
| 119 | return BytesArray(ctx.Out, results), nil |
| 120 | } |
| 121 | |
| 122 | // HExists returns if field is an existing field in the hash stored at key |
| 123 | func HExists(ctx *Context, txn *db.Transaction) (OnCommit, error) { |
nothing calls this directly
no test coverage detected