Hi Patrick,
I suppose that is more of logic than the tool itself and I suppose you
may enter the same problem in any DB you may change to (SQL or no-SQL).
Since CouchDB is using JavaScript, you could as well take advantage of
that and to set timer condition under userCtx for your user to be able
to create a document at a frequency no higher than one per minute. I am
sure there are other options as well, but here was what it came to my
mind on spot. I hope it will help you at least to think of other
possibilities.
Cheers,
CGS
On 10/20/2011 01:57 PM, Patrick Petermair wrote:
hey!
ist there a way to ensure some kind of unique constraint in couchdb
other than the document id?
for example:
we have multiple documents that each represent a timestamp of a user.
{ user: "[email protected]", timestamp: "2011-10-20T10:10" }
{ user: "[email protected]", timestamp: "2011-10-20T11:50" }
{ user: "[email protected]", timestamp: "2011-08-20T08:11" }
...
...
we now want to ensure, that a user can't have 2 documents with the
same timestamp .. basically creating a key for user + timestamp.
the solution so far is to create a view with a key of [user,
timestamp] and check after every document creation/update if there are
more than 1 documents for a given user + timestamp tuple.
this obviously has the performance penalty of having to do a seperate
db call. it also leaves the db in an inconsistent state until it is
resolved.
the other solution is to use the user + timestamp as document id. but
this would require to update the document id whenever the timestamp is
edited.
are there any other solutions? is there something on the roadmap for
couchdb that would solve our unique key problem? or is couchdb simply
the wrong tool for the job?
thanks!
patrick