Skip to content

Commit

Permalink
feat(firestore): Add String method for Update struct (#11355)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhshkh authored Jan 2, 2025
1 parent b7a7787 commit 2320c35
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions firestore/docref.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,13 @@ type transform struct {
err error
}

func (t transform) String() string {
if t.t == nil {
return ""
}
return t.t.String()
}

// FieldTransformIncrement returns a special value that can be used with Set, Create, or
// Update that tells the server to transform the field's current value
// by the given value.
Expand Down Expand Up @@ -664,6 +671,15 @@ type Update struct {
Value interface{}
}

// String returns string representation of firestore.Update
func (u Update) String() string {
t, ok := u.Value.(transform)
if !ok {
return fmt.Sprintf("Path: %s FieldPath: %s Value: %s", u.Path, u.FieldPath, u.Value)
}
return fmt.Sprintf("Path: %s FieldPath: %s Value: %s", u.Path, u.FieldPath, t.String())
}

// An fpv is a pair of validated FieldPath and value.
type fpv struct {
fieldPath FieldPath
Expand Down

0 comments on commit 2320c35

Please sign in to comment.