You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by faust 1111 <fa...@gmail.com> on 2010/04/01 20:51:54 UTC
Re: Validate uniqueness field
But in bulk updates its impossible to track uniqueness.
only when i update single doc i can before save delete old
uniq_doc(with _id = uniq_field_value) and create new.
2010/3/28 Jan Lehnardt <ja...@apache.org>:
> The only solution to enforce uniqueness on a field is using the _id field of a document. If you need two fields to be unique in a database, you'll need to use two documents for that.
>
> In addition, in the distributed case, the only way to ensure uniqueness is eventually, after replication, through conflicts that show up if two nodes created the same "unique" id.
>
> Cheers
> Jan
> --
>
> On 27 Mar 2010, at 20:41, faust 1111 wrote:
>
>> Why too documents?
>> But i have one issue User
>> i need only one document .
>>
>> i am interesting, how couch people do in real projects.
>> when they need two unique fields in document.
>>
>>
>> 2010/3/28 Jan Lehnardt <ja...@apache.org>:
>>> You need to have two documents with a unique ID each.
>>>
>>> Cheers
>>> Jan
>>> --
>>>
>>> On 27 Mar 2010, at 17:12, faust 1111 wrote:
>>>
>>>> but what if i have two unique fields
>>>> login
>>>> email
>>>>
>>>> 2010/3/28 J Chris Anderson <jc...@gmail.com>:
>>>>>
>>>>> On Mar 27, 2010, at 4:56 PM, faust 1111 wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> In what way i cat implement validation of uniqueness?
>>>>>> User
>>>>>> email: unique
>>>>>> login: unique
>>>>>>
>>>>>
>>>>> You can only have 1 unique field per database. you implement it by using it as a docid, like
>>>>>
>>>>> {
>>>>> "_id" : "user:unique",
>>>>> ...
>>>>> }
>>>>>
>>>>> Chris
>>>
>>>
>
>
Re: Validate uniqueness field
Posted by Adam Petty <ad...@gmail.com>.
In other words - this isn't really a Database Concern is it?
The Database doesn't care if these fields are unique - only your
application and in certain cases?
If your app needs certain cases as unique - create a method to update
a Unique Doc... that stores all unique ID's already used, or multiple
--
A touch more code, but building in scalability from the get go most likely.
--IMHO
On Thu, Apr 1, 2010 at 2:51 PM, faust 1111 <fa...@gmail.com> wrote:
> But in bulk updates its impossible to track uniqueness.
> only when i update single doc i can before save delete old
> uniq_doc(with _id = uniq_field_value) and create new.
>
> 2010/3/28 Jan Lehnardt <ja...@apache.org>:
>> The only solution to enforce uniqueness on a field is using the _id field of a document. If you need two fields to be unique in a database, you'll need to use two documents for that.
>>
>> In addition, in the distributed case, the only way to ensure uniqueness is eventually, after replication, through conflicts that show up if two nodes created the same "unique" id.
>>
>> Cheers
>> Jan
>> --
>>
>> On 27 Mar 2010, at 20:41, faust 1111 wrote:
>>
>>> Why too documents?
>>> But i have one issue User
>>> i need only one document .
>>>
>>> i am interesting, how couch people do in real projects.
>>> when they need two unique fields in document.
>>>
>>>
>>> 2010/3/28 Jan Lehnardt <ja...@apache.org>:
>>>> You need to have two documents with a unique ID each.
>>>>
>>>> Cheers
>>>> Jan
>>>> --
>>>>
>>>> On 27 Mar 2010, at 17:12, faust 1111 wrote:
>>>>
>>>>> but what if i have two unique fields
>>>>> login
>>>>> email
>>>>>
>>>>> 2010/3/28 J Chris Anderson <jc...@gmail.com>:
>>>>>>
>>>>>> On Mar 27, 2010, at 4:56 PM, faust 1111 wrote:
>>>>>>
>>>>>>> Hi
>>>>>>>
>>>>>>> In what way i cat implement validation of uniqueness?
>>>>>>> User
>>>>>>> email: unique
>>>>>>> login: unique
>>>>>>>
>>>>>>
>>>>>> You can only have 1 unique field per database. you implement it by using it as a docid, like
>>>>>>
>>>>>> {
>>>>>> "_id" : "user:unique",
>>>>>> ...
>>>>>> }
>>>>>>
>>>>>> Chris
>>>>
>>>>
>>
>>
>