Update embedded field in MongoDB using Golang

Hi @Vibhor_Dubey,

I’m not sure I have enough of your code to be able to sample run it myself, but I’m thinking the problem might be in your data structure.

You have JSON annotations on your fields, but to get proper bindings to document fields you want to use BSON annotations. For example:

type IMDBRegistry struct {
    MovieName   string                 `bson: "moviename" json:"moviename,omitempty"`
    Rating      string                 `bson: "rating" json:"rating,omitempty"`
    RatingCount int                    `bson: "peoplecount" json:"peoplecount,omitempty"`
    Comments    map[string]interface{} `bson: "comments" json:"comments,omitempty"`
}

I’m thinking your filter isn’t working correctly because the field mappings aren’t happening due to the missing BSON annotations.

You might also check out a Golang quickstart series I wrote which includes CRUD and annotations:

https://www.mongodb.com/quickstart/golang-change-streams

Let me know how it goes.

Best,