kokeksibir
kokeksibir

Reputation: 1745

Generating random unique IDs in a pattern in CouchDb

In a web app using CouchDB I need to generate unique IDs that consists of Two letters and six digit number, which is used as key in url to access document. IDs will be random, not sequential. What is the best practice to perform this?

Upvotes: 1

Views: 442

Answers (1)

Kxepal
Kxepal

Reputation: 4679

Use update handlers to create/update docs with _id value that fits your requirements and validation functions to verify that stored document has valid _id field.

The implementation of _id generator function should be very easy. See related question here on StackOverflow for example.

Upvotes: 1

Related Questions