
If you want to query documents that use different schemas you can create a schema with the properties of all your schemas and do Schema.find() with that. The problem was that the collection has several different schemas and the specific schema I was using didn't have the fragments property. I would really appreciate some help here because I am stumped. If it helps, there are other documents in this collection that don't follow this schema. MongoDB Compass provides a native GUI to analyze collections and beautifully visualize your schema. With MongoDB 3.2, we answered our users with MongoDB Compass v1.0 a GUI schema visualization tool and query builder.
MONGODB COMPASS AND QUERY CODE
It’s open source and the code is available in Github.When I try in Compass and my code, but it's like the other query. Over the past couple of years, we have received an overwhelming number of requests for a schema visualizer and query builder.

Var guidDecoded = new Guid(bytes.Slice(0, bytesWritten).ToArray()).ToString() įinally, if you just need it now without writing code use a Blazor WebAssembly app I made just for this. If (Convert.TryFromBase64String("YOUR_BASE64_STRING_HERE", bytes, out int bytesWritten)) Var bytes = new Span(new byte) //arbitrary number Var base64Encoded = Convert.ToBase64String("YOUR_GUID_HERE") Īnd here is a way to decode a base64 string that contains GUID bytes: Solutionįollows a C# solution which is simple enough, but of course requires to at least copy-paste the code to a project and run it: Worth mentioning here that we were working on this problem with Dean Herringer and he was the first to notice the problem. No matter how many times I attempted to convert the GUID using various online services to its base64 equivalent, I always failed because these services were converting the GUID to base64 as string!Īnd there’s your problem! Encoding a GUID’s bytes is different than encoding GUID’s representative string value.

The value you see is actually a base64 encoded string of the GUID value.Īnd everything was cool for years, up until I had to manually debug a situation where I had to connect directly to MongoDB to search for a document based on a GUID I knew. Far from the previous useless sentence though, mind the blue square because this is how MongoDB stores a GUID. The capture above is showing a part of MongoDB compass connected to a beta database with partially real but old data, located locally.

Nevertheless, the schema above gave room for some beautiful data like the following image, with some databases and collections ending up having millions of data located in an availability zone probably near you! The schema of the document is not very important other than the fact that the ID should be of type GUID:

Some time ago I created a project for storing product prices but for multiple markets around the world. Have you ever tried to query MongoDB with a GUID? Well I did and it can be confusing!
