lundi 19 février 2018

generate unique ID in Ember JS or CouchDB

I'm currently using CouchDB/PouchDB as a back-end for my Ember app.

The database automatically generates an unique UUID of 64 letters and numbers for each record, which is good for finding records and ensuring there are never any duplicates.

But my client wants each record to have a simple ID of 001, 002, 003, etc.

This doesn't have to be the actual ID for each record, this would be something like record_idand would only be used by my client internally, for his own convenience (so just a normal integer field, no index or key)

This is super-easy to do in MySQL, since all you have to do is add a primary key. But I'll admit that my knowledge of CouchDB is still pretty limited.

Basically, I'd like to generate simple, auto-incrementing and unique IDs using Ember.js - or CouchDB.

I can't find any way to do this easily, which is quite surprising. This seems like a very common requirement, but I can't find a good solution after about an hour of googling.

Has anyone ever done this before, or do you have any suggestions? I'm out of ideas.

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire