Currently I already use NewRegistryBuilder()
in the mongo client options , Somehow i want to make use of NewRespectNilValuesRegistryBuilder()
from mongocompact so that I can set the nilvalues in the []models as empty array .
Currently I have something like below , To map the old mgo behavior
tM := reflect.TypeOf(bson.M{})
registry := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().ApplyURI(URI).SetAuth(info).SetRegistry(registry)
client, err := mongo.Connect(ctx, clientOpts)
Now somehow I want to incorporate and set the NewRespectNilValuesRegistryBuilder().Build()
to true in the same connect options , Not sure how to do that . Also the other problem that i see is i'm not able to see the mongocompat registry file in my vendor directory
can i do something like this , SetRegistry()
two times ? like below ?
tM := reflect.TypeOf(bson.M{})
registry := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().ApplyURI(SOMEURI).SetAuth(info).SetRegistry(registry)
//not sure if the below line is of right usage ??
clientOpts.SetRegistry(NewRespectNilValuesRegistryBuilder().Build())
client, err := mongo.Connect(ctx, clientOpts)
can anyone help me with this ?
related issue here