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.
1 parent 904d7b2 commit d672a80Copy full SHA for d672a80
utils/xid.go
@@ -1,8 +1,9 @@
1
package utils
2
3
import (
4
+ "encoding/json"
5
+
6
"github.com/rs/xid"
- "go.mongodb.org/mongo-driver/bson"
7
)
8
9
type XID string
@@ -15,15 +16,13 @@ func (id *XID) String() string {
15
16
}
17
18
func (id XID) MarshalBSON() ([]byte, error) {
- return bson.Marshal(struct {
19
- ID string
20
- }{string(id)})
+ return json.Marshal(&id)
21
22
23
func (id *XID) UnmarshalBSON(data []byte) error {
24
var tmp struct{ ID string }
25
26
- if err := bson.Unmarshal(data, &tmp); err != nil {
+ if err := json.Unmarshal(data, &tmp); err != nil {
27
return err
28
29
0 commit comments