You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/migration-2.0.md
+14-2Lines changed: 14 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1183,8 +1183,20 @@ A new `RawArray` type has been added to the `bson` package as a primitive type t
1183
1183
1184
1184
### ValueMarshaler
1185
1185
1186
-
The `MarshalBSONValue` method of the `ValueMarshaler` interface is only required to return a byte type value representing the BSON type to avoid importing the `bsontype` package.
1186
+
The `MarshalBSONValue` method of the `ValueMarshaler` interface is only required to return a byte type value representing the BSON type to avoid importing the `bsontype` package. Comparison can be achieved by type asserting with `bson.Type`. For example:
1187
+
1188
+
```go
1189
+
btype, _, _:= m.MarshalBSONValue()
1190
+
fmt.Println("type of data: %s: ", bson.Type(btype))
1191
+
fmt.Println("type of data is an array: %v", bson.Type(btype) == bson.TypeArray)
1192
+
```
1187
1193
1188
1194
### ValueUnmarshaler
1189
1195
1190
-
The `UnmarshalBSONValue` method of the `ValueUnmarshaler` interface is only required to take a byte type argument representing the BSON type to avoid importing the Go driver package.
1196
+
The `UnmarshalBSONValue` method of the `ValueUnmarshaler` interface is only required to take a byte type argument representing the BSON type to avoid importing the Go driver package. For example:
0 commit comments