The application saves the Guid field in Mongo, and it ends up storing it as BinData:
"_id" : new BinData(3, "WBAc3FDBDU+Zh/cBQFPc3Q==")
The advantage in this case is compactness, the disadvantage is manifested when you need to troubleshoot an application. Guides are passed through URLs and constantly convert them to BinData when switching to the Mongo console it is a little painful.
What are the disadvantages of storing guid as strings in addition to increasing size? One advantage is the ease of troubleshooting:
"_id" : "3c901cac-5b90-4a09-896c-00e4779a9199"
Here is a prototype of a permanent object in C #:
class Thing { [BsonIgnore] public Guid Id { get; set; } [BsonId] public string DontUseInAppMongoId { get { return Id.ToString(); } set { Id = Guid.Parse(value); } } }
Yuriy zubarev
source share