Hello members.

I would like to remove node 'dd' with children at once (or twice) 
operation. 

I wrote below code, It works. 
But I would like to use sub-query for huge nodes. 

It is possible to use sub-query or something for that?

Like this 

  FileTree.filter(:id => dd.all_children_data_set ).delete
  FileTree.filter(:id => dd.id).delete


Below is my code.

DataBase = Sequel.connect("sqlite://test.db")

class FileTree < Sequel::Model
  plugin :rcte_tree, :single_root => true
end

DataBase.transaction do 
  root = FileTree.root
  node = root.children_dataset.first(:name=>'dd')
  ids = node.descendants.map(&:id)
  ids << node.id

  FileTree.filter(:id => ids).delete
end

This is a tree. example.

 / -- aa
   +- bb
   +- cc
    +- dd
        +-- d1
        +-- d1
        +-- d2
        +-- d3
        +-- d4
        +-- d5
        +-- d6
        +-- d7
             +-- d7-1
             +-- d7-2
             +-- d7-3
             +-- d7-4
             +-- d7-5

Best regards.

--
Hiroyuki Sato.









                

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to