Skip to content

Commit

Permalink
feat(spanner): Add ReadRowWithOptions method
Browse files Browse the repository at this point in the history
  • Loading branch information
shuheiktgw committed Dec 21, 2021
1 parent 4438aeb commit 96afde1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion spanner/transaction.go
Expand Up @@ -212,7 +212,15 @@ func errMultipleRowsFound(table string, key Key, index string) error {
// If no row is present with the given key, then ReadRow returns an error where
// spanner.ErrCode(err) is codes.NotFound.
func (t *txReadOnly) ReadRow(ctx context.Context, table string, key Key, columns []string) (*Row, error) {
iter := t.Read(ctx, table, key, columns)
return t.ReadRowWithOptions(ctx, table, key, columns, nil)
}

// ReadRowWithOptions reads a single row from the database. Pass a ReadOptions to modify the read operation.
//
// If no row is present with the given key, then ReadRowWithOptions returns an error where
// spanner.ErrCode(err) is codes.NotFound.
func (t *txReadOnly) ReadRowWithOptions(ctx context.Context, table string, key Key, columns []string, opts *ReadOptions) (*Row, error) {
iter := t.ReadWithOptions(ctx, table, key, columns, opts)
defer iter.Stop()
row, err := iter.Next()
switch err {
Expand Down

0 comments on commit 96afde1

Please sign in to comment.