Hi Olaf, > On 10. Jul 2020, at 14:03, Olaf Krüger <[email protected]> wrote: > > Hi guys, > > before reading the docs I was afraid of creating custom _ids. > But the docs [1] even says that we shouldn't rely on the auto generated UUID. > > Our primary goal is to create more human readable _ids. > So, in order to avoid conflicts, the idea is to introduce scoped custom _ids > which starts e.g. with a leading namespace followed by a short id, e.g.: > > INV-HG6FU > > (The length of the short id depends on the expected number of documents for a > certain scope/doc type) > > However, before going this way I would like to know if there are any > drawbacks with such approach and how others achieve this.
This is a fine approach. The only drawback is when your expectation ends up not holding, but then you could just lengthen the id one by one to get more space. > Or should we rather rely on the auto-UUID and move custom ids into its own > document property, something like e.g. "publicId”? This also works, bur your original idea is also fine. — I think what the docs want to convey is that avoiding accidental duplicates on network-retries is the main reason for this advice. You can also retrieve UUIDs from CouchDB’s to assign to docs on the client if you don’t have your own. In addition, CouchDB’s default UUID scheme produces UUIDs in sequential batches[1], that make inserts more efficient. If you can reproduce this in your external IDs, your get the same benefits. [1]: https://github.com/apache/couchdb/blob/master/rel/overlay/etc/default.ini#L372-L375 Best Jan — Professional Support for Apache CouchDB: https://neighbourhood.ie/couchdb-support/ > > Many thanks in advance! > > Olaf > > [1] > https://docs.couchdb.org/en/stable/best-practices/documents.html#don-t-rely-on-couchdb-s-auto-uuid-generation > >
