Changes

Jump to navigation Jump to search
2,776 bytes added ,  13:25, 3 January 2014
Created page with "== NAME == esmith::DB::Record - an individual record in an E-Smith database In a root terminal you can do the command below if you want to display the up-to-date content per..."
== NAME ==
esmith::DB::Record - an individual record in an E-Smith database
In a root terminal you can do the command below if you want to display the up-to-date content
perldoc esmith::DB::Record
== SYNOPSIS ==
DO NOT USE THIS CLASS DIRECTLY! use via esmith::DB.

my $key = $record->key;

my %properties = $record->props;

my $value = $record->prop($prop_key);
$record->set_prop($prop_key, $prop_val);

my $value = $record->delete_prop($prop_key);

$record->merge_props(%more_properties);
$record->reset_props(%new_properties);

$record->delete;

print $record->show;

== DESCRIPTION ==
This class is a general interface to individual records in esmith::DB databases. It should not be used directly, but rather esmith::DBs should hand you esmith::DB::Record objects.

Each subclass of esmith::DB will also have to subclass and implement an esmith::DB::Record subclass.
=== Virtual Methods ===

==== key ====
my $key = $record->key;

Returns the $key for this $record;

==== props ====
my %properties = $record->props;
my $num_props = $record->props;

Returns a hash of all the properties for this $record. In scalar context it will return the number of properties this $record has.

=== prop ===
==== set_prop ====
my $value = $record->prop($property);
$record->set_prop($property, $value);

Gets/sets the $value of the $property in this $record.

set_prop() will die if the database is read-only.

==== delete_prop ====
my $value = $record->delete_prop($property);

Deletes a $property from the $record, returning the old $value.
delete_prop() will die if the database is read-only.

==== merge_props ====
$record->merge_props(%properties);

Adds the %properties to the $records existing properties. Any new keys will be added, any existing keys will be overwritten.

merge_props() will die if the database is read-only.

==== reset_props ====
$record->reset_props(%properties);

Replaces the $record’s properties with the contents of %properties. Any old properties will be deleted.

reset_props() will die if the database is read-only.

==== delete ====
$record->delete;

Deletes the $record from its database.

delete() will die if the database is read-only.

=== Concrete methods ===

==== show ====
my $formatted = $record->show;
Returns the $record’s key and properties in a nice, human readable format suitable for printing.

== SEE ALSO ==
[http://wiki.contribs.org/Esmith::DB esmith::DB]

[[Category:Developer]]
[[Category:SME Server Development Framework]]
[[Category:Development Tools]]

Navigation menu