incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Coffman, Timothy A" <tim.coff...@Vanderbilt.Edu>
Subject Re: Modeling question
Date Tue, 05 Jan 2010 19:56:27 GMT
Joscha,
    If you emit every A, B, and C, with keys:
       for A's : [ id_of_self, null, null ]
       for B's : [ id_of_parent, id_of_self, null ]
       for C's : [ id_of_grandparent, id_of_parent, id_of_self ]

Then a query with startkey: [ a, null, null ]  and endkey: [ a, {}, {} ] will give you all
documents that are A or children of A.  With that set, you could determine the appropriate
combination of ACL's to use.

I hope I have that right.

On 05.01.10 18:49, Chris Anderson wrote:

> if you collate correctly and use startkey and endkey you will be be
> able to read just the relevant rows from the view. This should be
> practically instantaneous, so it's probably the right solution.

Actually this is only true for A's (I do this already), as any B or C
does not necessarily have its own access field.
As it is not possible to temporary store variables in a map function,
there is no way I can distribute the acl from a parent element (such as
A or B) into a child element (B or C).
I could misuse reduce probably, but as this is discouraged, I did not
even try.
Also an A does not have any information about its children, so when
emitting an A (which will most likely contain the access information), I
can not also emit that information for any child (B or C).
This makes using starkey and endkey only suitable for A's but not for
any child element in the hierarchy.

Any other ideas?

> I mentioned before, but I'll mention again - if there's a way to
> achieve your business case without modeling a hierarchy (always an
> impedance mismatch with key value stores) you will simplify a lot of
> things. Not that it's impossible to do a hierarchy, but if you can get
> away without it, you'll have a lot less on your plate.

I've read that multiple times, but you know there are these times when a
hierarchy just is needed.

regards,
Joscha

Tim Coffman
Vanderbilt University Medical Center
(615) 936-6496


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message