I am attempting to create document structs without setting an _id to prevent duplication. However, I still need to access the _id. In my current implimentation, I am using dson::dafaut(). Is there a way to do this or is my current method the best option?

Hi @Reece_A and welcome to the community forum

The above statement is not very clear on your requirement. Could you please provide some more details and clarify the statement ?
The _id in MongoDb is created by default when a document is inserted inside the collection. This prevents duplication and ensures each document has a unique identifier. In your case, it sounds like you are using a system similar to MongoDB, where the _id field is typically generated by the database if not provided.

If you still wish to access the _id in your implementation, insert the document without explicitly setting the _id field. The database will automatically generate a unique _id.
After insertion, you can access the document with the auto generated _id .

Regards
Aasawari