Skip to content

Commit a0d6ea8

Browse files
authored
Merge pull request #7 from sendinblue/CC-3396
CC-3396 - Add support for ReadRow, to query only required columns
2 parents 13de23b + 0c32654 commit a0d6ea8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

repository/repository.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ func (r *Repository) ReadLast(ctx context.Context, key string) (*data.Set, error
7676
return r.read(ctx, key, bigtable.RowFilter(bigtable.LatestNFilter(1)))
7777
}
7878

79+
// ReadRow reads a row from the repository while returning the cell values after
80+
// mapping it to a data.Set. This method takes a row key as an argument, uses its internal adapter
81+
// to read the row from Big Table, parses only the cells contained in the row to turn it into
82+
// a map of data.Event and finally returns the data.Set that contains all the events.
83+
func (r *Repository) ReadRow(ctx context.Context, key string, opts ...bigtable.ReadOption) (*data.Set, error) {
84+
row, err := r.adapter.ReadRow(ctx, key, opts...)
85+
if err != nil {
86+
return nil, err
87+
}
88+
return buildEventSet([]bigtable.Row{row}, r.mapper), nil
89+
}
90+
7991
func (r *Repository) read(ctx context.Context, key string, opts ...bigtable.ReadOption) (*data.Set, error) {
8092
row, err := r.adapter.ReadRow(ctx, key, opts...)
8193
if err != nil {

0 commit comments

Comments
 (0)