Collection.InsertOne()
returns a *InsertOneResult
, which only contains the ID of the inserted document. To get the inserted document, you have to perform another Collection.Find()
query. Is there a way to do this in a single step?
A current work around is to use Collection.FindOneAndUpdate()
with Upsert
set to true, as this returns a *SingleResult
that can then be decoded into a struct, and sent back to the client.