In mongodb-go-driver, how to marshal/unmarshal BSON in to a struct

后端 未结 4 854
野趣味
野趣味 2021-02-05 21:19

I am new to mongodb-go-driver. But i am stuck.

cursor, e := collection.Find(context.Background(), bson.NewDocument(bson.EC.String(\"name\", id)))

for cursor.Nex         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-05 22:18

    I was getting

    cannot decode objectID into an array

    so i changed to

    ID interface{} `bson:"_id,omitempty"`

    without any issues

提交回复
热议问题