Skip to content

Instantly share code, notes, and snippets.

@siddontang
Created May 3, 2018 19:43
Show Gist options
  • Save siddontang/efa08d318244299097df0b0e6ad6774b to your computer and use it in GitHub Desktop.
Save siddontang/efa08d318244299097df0b0e6ad6774b to your computer and use it in GitHub Desktop.
func (db *fDB) Read(ctx context.Context, table string, key string, fields []string) (map[string][]byte, error) {
rowKey := db.getRowKey(table, key)
row, err := db.db.Transact(func(tr fdb.Transaction) (interface{}, error) {
f := tr.Get(fdb.Key(rowKey))
return f.Get()
})
if err != nil {
return nil, err
} else if row == nil {
return nil, nil
}
return db.r.Decode(row.([]byte), fields)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment