You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Benoit Chesneau <bc...@gmail.com> on 2011/04/27 12:31:14 UTC

doc `_user` member proposal

hi all,

more and more I'm adding for validation purpose an author property ==
couchdb username in my docs . This is always the user connected and
I'm currenty asking myself if we couldn't do it automatically on doc
save/update.

We could add a _user member to the doc and have its value  equal to
name field in the user_ctx. So we can validate against it and compare
with the db security object in validation functions. What do you think
about it ?

- benoît

Re: doc `_user` member proposal

Posted by Benoit Chesneau <bc...@gmail.com>.
On Wed, Apr 27, 2011 at 1:07 PM, Robert Newson <ro...@gmail.com> wrote:
> Hm, I don't get it then. Why add a reserved field? doesn't 'user' work
> just as well for those folks that want write validation functions
> and/or replication filters?
>
> B.
>
cause i want this field specific to the user_ctx, so afaik it's a
private member in doc that you shouldn't override like _rev rather
than a field added by the application.

- benoit

Re: doc `_user` member proposal

Posted by Robert Newson <ro...@gmail.com>.
Hm, I don't get it then. Why add a reserved field? doesn't 'user' work
just as well for those folks that want write validation functions
and/or replication filters?

B.

On 27 April 2011 12:00, Benoit Chesneau <bc...@gmail.com> wrote:
> On Wed, Apr 27, 2011 at 12:54 PM, Robert Newson <ro...@gmail.com> wrote:
>> Is the purpose of this to just save adding a validate_doc_update that
>> throws if doc._user != userCtx.name?
>>
>> B.
>>
> No my proposoal is adding this _user member to doc like _rev and _id,
> so we can use it in validate_update functions, shows, changes filters
> or anything where we can access to this property.
>
> In case of a change filter we could restrict a feed to a user or if
> the user is in group (would imply to pass the db security object to
> the change filter, which we should do imo).
>
> - benoit
>

Re: doc `_user` member proposal

Posted by Benoit Chesneau <bc...@gmail.com>.
On Wed, Apr 27, 2011 at 12:54 PM, Robert Newson <ro...@gmail.com> wrote:
> Is the purpose of this to just save adding a validate_doc_update that
> throws if doc._user != userCtx.name?
>
> B.
>
No my proposoal is adding this _user member to doc like _rev and _id,
so we can use it in validate_update functions, shows, changes filters
or anything where we can access to this property.

In case of a change filter we could restrict a feed to a user or if
the user is in group (would imply to pass the db security object to
the change filter, which we should do imo).

- benoit

Re: doc `_user` member proposal

Posted by Robert Newson <ro...@gmail.com>.
Is the purpose of this to just save adding a validate_doc_update that
throws if doc._user != userCtx.name?

B.

On 27 April 2011 11:31, Benoit Chesneau <bc...@gmail.com> wrote:
> hi all,
>
> more and more I'm adding for validation purpose an author property ==
> couchdb username in my docs . This is always the user connected and
> I'm currenty asking myself if we couldn't do it automatically on doc
> save/update.
>
> We could add a _user member to the doc and have its value  equal to
> name field in the user_ctx. So we can validate against it and compare
> with the db security object in validation functions. What do you think
> about it ?
>
> - benoît
>