Working with multiple databases (DAO Pattern)


I am creating a project which should be able to use different databases for the persistence of data. I have implemented a DAO pattern, but I have a problem when working with the ID in the struct, since for example MongoDB uses BSON whereas SQL databases use uint.

What solution do you recommend to implement the ID field in the struct.

What I can think of is to create an ID object that contains fields for BSON and uint IDs with GetBSON, GetUint methods and a GetID method that encodes either BSON or uint to MD5 (or some other encoding) I would use the GetBSON and GetUint methods to work with the Databases and the GetID method to work on the application as well as to send it through the REST API.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.