I have a diary App where I want to have a single document for each day. My question is if it would be a good practise to use an ISO 8601 datetime String as a document Id. Because every day can only have one document it would be an unique Id.
Or should I store the date in the document and use a random document Id? What would be a better choice?
One querie I want to do is check if there is an document with a specific date (for example today). If so, I want to fetch this document, otherwhise If there is no document for today I want to create one.
Using the value that you want to be unique as the document ID is an easy (and in many cases the only) way to ensure uniqueness. As long as the limit on throughput for such sequential keys is acceptable for your use-case (which seems to be the case here), it is a good, simple method of ensuring uniqueness.