Metadata::DB::File - metadata object about a file


   use Metadata::DB::File;
   my $f = Metadata::DB::File->new({ 
      DBH => $dbh, 
      abs_path => '/home/myself/file',

   $f->set('client' => 'James Mahoney');      
   my $id1 = $f->id;


   my $f2 = Metadata::DB::File->new({ DBH => $dbh, id => $id1 });   
   $f2->get('client'); #  eq 'James Mahoney'

   my $f = Metadata::DB::File::Base->new({ 
      DBH => $dbh, 
      abs_path => '/home/myself/this',
      host_id => 3,      


This is the 'file' counterpart to Metadata::DB::Base

This lets you store metadata in a database, about a file on disk The system is extremely adaptive. The manner in which we store metadata and the way in which we store information on what the resources are, is separate.

You can store info on many files on many computers.

To load the file data. The object must know which record you are referring to. You can tell it either the id, or the absolute path and host to record.


In addition to all the methods in Metadata::DB::Base ..


you can specify arguments 'id' or 'abs_path', and optionally 'host_id' otherwise you should use file_set()

      file id, same as in metadata table, only reason you should have this
      for the constructor is out of a search query
      absolute path to file

      optional, not currently implemented, but you could use it
      boolean, if we should normalize the paths with Cwd::abs_path
      if a host id is set, will ignore
      default is 0


is record in metadata table by id? (See Metadata::DB)


is the record in files table by path? (and host_id if set)


argument is file id or abs_path and optionally host_id

   $f->file_set('/home/hi/there',4); # with host id
   $f->file_set(43); # via id only

if first arg is a number, we interpret as an id


returns abs path, must be set via constructor


returns host id if any is set




   use Metadata::DB::File::Base;

   my $s = Metadata::DB::File::Base->new({ DBH => $dbh });




Metadata::DB Metadata::DB::File::Base

I would like to be able to instance these ways:

Example 1

   my $f = Metadata::DB::File::Base->new({
      DBH => $dbh,


   $f->set( age => 4 ); # does not need to call load or save

   $f->get('author'); # calls load, does NOT generate id unless there already

   $f->set( author => 'leo' ); # does not call load, does not generate id

   $f->id; # will call load, will generate id if not there


Example 2

   my $f = Metadata::DB::File::Base->new({
      DBH => $dbh,

   $f->id_set(2); # calls load, does NOT generate id, croaks if not in db

   $f->get('author'); # calls load


   how the identity should be determined

   )) via constructor id
      if an id is in the constructor
      should we write to db immediately?? No



   )) via constructor abs_path

      if abs path is in const arg
      and we ask for id, we should return undefined unless we saved or loaded

   )) via id_set
      id set should ONLY accept the value IF it is already in database
      id set should warn and return undef if not in db (files table)


   )) via abs_path_set
      this should not save to db auto.. ?
      if you set abs path, 
         and then request id 
         and the id is not in the db
         then none is returned, and you are warned to save first
         before you get an id


   # if you set abs path and then request id, that should make sure an entry is in the db???