We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents cf1b35a + 83d7a3a commit 3603ec7Copy full SHA for 3603ec7
bson/value.go
@@ -553,6 +553,16 @@ func (v *Value) Binary() (subtype byte, data []byte) {
553
return st, b
554
}
555
556
+// BinaryOK is the same as Binary, except it returns a boolean instead of
557
+// panicking.
558
+func (v *Value) BinaryOK() (subtype byte, data []byte, ok bool) {
559
+ if v == nil || v.offset == 0 || v.data == nil || Type(v.data[v.start]) != TypeBinary {
560
+ return 0x00, nil, false
561
+ }
562
+ st, b := v.Binary()
563
+ return st, b, true
564
+}
565
+
566
// ObjectID returns the BSON objectid value the Value represents. It panics if the value is a BSON
567
// type other than objectid.
568
func (v *Value) ObjectID() objectid.ObjectID {
0 commit comments