diff --git a/src/dbAccess/client.go b/src/dbAccess/client.go index c7223e4..b9b5579 100644 --- a/src/dbAccess/client.go +++ b/src/dbAccess/client.go @@ -41,11 +41,16 @@ func getDbUri() string { // Provide the DB Connection to other functions var MongoClient (*mongo.Client) = initDataAccess() +// Configure bsonOpts +var bsonOpts = &options.BSONOptions{ + UseJSONStructTags: true, +} + // Initialise the DB Connection func initDataAccess() *mongo.Client { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - client, err := mongo.Connect(ctx, options.Client().ApplyURI(dbUri)) + client, err := mongo.Connect(ctx, options.Client().ApplyURI(dbUri).SetBSONOptions(bsonOpts)) if err != nil { fmt.Println(err) log.Msg.Fatal("Error connecting to database: " + err.Error())