Skip to content

Commit

Permalink
Merge branch 'pr/85'
Browse files Browse the repository at this point in the history
Change-Id: Iba05860c670857bdaadb394a5d05e410d3746fab
  • Loading branch information
skriptble committed Sep 20, 2018
2 parents cf1b35a + 83d7a3a commit 3603ec7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bson/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,16 @@ func (v *Value) Binary() (subtype byte, data []byte) {
return st, b
}

// BinaryOK is the same as Binary, except it returns a boolean instead of
// panicking.
func (v *Value) BinaryOK() (subtype byte, data []byte, ok bool) {
if v == nil || v.offset == 0 || v.data == nil || Type(v.data[v.start]) != TypeBinary {
return 0x00, nil, false
}
st, b := v.Binary()
return st, b, true
}

// ObjectID returns the BSON objectid value the Value represents. It panics if the value is a BSON
// type other than objectid.
func (v *Value) ObjectID() objectid.ObjectID {
Expand Down

0 comments on commit 3603ec7

Please sign in to comment.