You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Patrick Barnes <mr...@gmail.com> on 2010/05/27 06:38:17 UTC

Re: Delete document Tree Structure

How do you currently organise the documents into a tree and display them?

For my trees, I have a 'hierarchy' array attribute that basically holds 
a tree address, eg:
A = {"_id":"A", .... "hierarchy":["A"]};
B = {"_id":"B", .... "hierarchy":["B"]};
C = {"_id":"C", .... "hierarchy":["B","C"]};
D = {"_id":"D", .... "hierarchy":["A","D"]};
E = {"_id":"C", .... "hierarchy":["B","E"]};
F = {"_id":"C", .... "hierarchy":["B","E","F"]};

If you then create a view that emits the hierarchy attribute as the key, 
it will automatically sort them into lexicographic (tree) order.

If you want to delete B+descendants, you:
1. Query that view with:
  startkey=["B"] &
  endkey=["B",{}]
to get the B document and every descendant of B,
2. Delete them all.

On 27/05/2010 1:48 PM, Aun... ��Ǿ��� wrote:
>
>
> Hi,
>
>         I design document in couchdb to have relation something like
>
>                directory
>                      |
>                      A---------D
>                      |
>                      B---------C
>                                   |
>                                   |
>                                   E ------F
>
>           if i would like to http (DELETE B) will delete all down documents what is the possible solution to use.
>
>                  1.    can i create view and find relation and delete all of them ?
>                  2.    get  relation by higher programming api (C#,PHP) and then delete each one?
>                  3.    Do you have any solution to suggest on this.....?
>
>
> Thanks,
> A.
>
>
>   		 	   		
> _________________________________________________________________
> Hotmail: ��ԡ������ſ�� ������Ͷ���� �������ó�����
> https://signup.live.com/signup.aspx?id=60969