Dear members.
I'm newbie Sequel.
Could you tell me best approach and example to represent Unix directory
hierarchy with Sequel and Sqlite3?
Especially, I would like to know the following
How to find '/path/to/deepchild' node with small cost.
It's tree, and I found rcte_tree plugin. and I wrote the following code.
Alternatively, Should I uses "Nested Sets Model" for that?
Sincerely.
require 'sqlite3'
require 'sequel'
require 'pp'
dbpath = File.expand_path(File.dirname(__FILE__),"tree.db")
DB = Sequel.connect("sqlite://#{dbpath}")
unless DB.table_exists?(:file_trees)
# create table
DB.create_table :file_trees do
primary_key :id
String :name
Integer :uid
Integer :gid
# And some attributes
Numeric :parent_id
end
end
class FileTree < Sequel::Model
plugin :rcte_tree, :single_root => true
end
FileTree.create(:name => "root")
FileTree.create(:name => "child",:parent_id => FileTree.root.id)
My Goal
represent common file operation logging like the following.
* create new node in '/path/to/deepchild'
* list child in '/path/to/deepchild'
* move node from '/path/to/a' to '/new/path/b'
* remove node '/path/to/a' and child.
* copy node '/path/to/a' to '/new/path/to/b'
--
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.