title: Update/Replace mongodb document using struct & mongodb/mongo-go-driver
body: <p>I am trying to update/replace a mongodb document using a struct but i keep on getting <code>err: update document must contain key beginning with '$'</code></p>
  
  <pre><code>collection := r.client.Database(database).Collection(greetingCollection)
  payment.MongoID = objectid.New()
  filter := bson.NewDocument(bson.EC.String("id", payment.ID))
  _, err := collection.UpdateOne(ctx, filter, payment)
  return err
  </code></pre>