Biblio-Zotero-DB
view release on metacpan or search on metacpan
lib/Biblio/Zotero/DB/Schema/Result/Item.pm view on Meta::CPAN
use utf8;
package Biblio::Zotero::DB::Schema::Result::Item;
$Biblio::Zotero::DB::Schema::Result::Item::VERSION = '0.004';
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->table("items");
__PACKAGE__->add_columns(
"itemid",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"itemtypeid",
{ data_type => "int", is_nullable => 0 },
"dateadded",
{
data_type => "timestamp",
default_value => \"current_timestamp",
is_nullable => 0,
},
"datemodified",
{
data_type => "timestamp",
default_value => \"current_timestamp",
is_nullable => 0,
},
"clientdatemodified",
{
data_type => "timestamp",
default_value => \"current_timestamp",
is_nullable => 0,
},
"libraryid",
{ data_type => "int", is_foreign_key => 1, is_nullable => 1 },
"key",
{ data_type => "text", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("itemid");
__PACKAGE__->add_unique_constraint("libraryid_key_unique", ["libraryid", "key"]);
__PACKAGE__->has_many(
"collection_items",
"Biblio::Zotero::DB::Schema::Result::CollectionItem",
{ "foreign.itemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->might_have(
"fulltext_item",
"Biblio::Zotero::DB::Schema::Result::FulltextItem",
{ "foreign.itemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"fulltext_item_words",
"Biblio::Zotero::DB::Schema::Result::FulltextItemWord",
{ "foreign.itemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->might_have(
"item_attachments_itemid",
"Biblio::Zotero::DB::Schema::Result::ItemAttachment",
{ "foreign.itemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"item_attachments_sourceitemids",
"Biblio::Zotero::DB::Schema::Result::ItemAttachment",
{ "foreign.sourceitemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"item_creators",
"Biblio::Zotero::DB::Schema::Result::ItemCreator",
{ "foreign.itemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"item_datas",
"Biblio::Zotero::DB::Schema::Result::ItemData",
{ "foreign.itemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->might_have(
"item_notes_itemid",
"Biblio::Zotero::DB::Schema::Result::ItemNote",
{ "foreign.itemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"item_notes_sourceitemids",
"Biblio::Zotero::DB::Schema::Result::ItemNote",
{ "foreign.sourceitemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"item_see_also_itemids",
"Biblio::Zotero::DB::Schema::Result::ItemSeeAlso",
{ "foreign.itemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"item_see_also_linkeditemids",
"Biblio::Zotero::DB::Schema::Result::ItemSeeAlso",
{ "foreign.linkeditemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"item_tags",
"Biblio::Zotero::DB::Schema::Result::ItemTag",
{ "foreign.itemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->belongs_to(
"libraryid",
"Biblio::Zotero::DB::Schema::Result::Library",
{ libraryid => "libraryid" },
{
is_deferrable => 0,
join_type => "LEFT",
on_delete => "NO ACTION",
on_update => "NO ACTION",
},
);
__PACKAGE__->many_to_many("itemids", "item_see_also_linkeditemids", "itemid");
__PACKAGE__->many_to_many("linkeditemids", "item_see_also_linkeditemids", "linkeditemid");
__PACKAGE__->many_to_many("tagids", "item_tags", "tagid");
__PACKAGE__->many_to_many("wordids", "fulltext_item_words", "wordid");
# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-07-02 23:02:38
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OcWFl3GnRhMxSUTwxOnJCw
# NOTE: extended DBIC schema below
sub is_attachment {
my $self = shift;
!! defined $self->item_attachments_itemid;
}
sub is_source_item {
my $self = shift;
!! $self->item_attachments_sourceitemids->count;
}
# TODO: document
sub tag_names {
my ($self) = @_;
[map { $_->name } $self->tagids];
}
# TODO: document
sub fields {
my ($self) = @_;
$self->item_datas_rs->fields_for_itemid($self->itemid);
}
__PACKAGE__->has_many(
"stored_item_attachments_sourceitemids",
"Biblio::Zotero::DB::Schema::Result::StoredItemAttachment",
{ "foreign.sourceitemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"trash_item_attachments_sourceitemids",
"Biblio::Zotero::DB::Schema::Result::TrashItemAttachment",
{ "foreign.sourceitemid" => "self.itemid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Biblio::Zotero::DB::Schema::Result::Item
=head1 VERSION
version 0.004
=head1 NAME
Biblio::Zotero::DB::Schema::Result::Item
=head1 TABLE: C<items>
=head1 ACCESSORS
=head2 itemid
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 itemtypeid
data_type: 'int'
is_nullable: 0
=head2 dateadded
data_type: 'timestamp'
default_value: current_timestamp
is_nullable: 0
=head2 datemodified
data_type: 'timestamp'
default_value: current_timestamp
is_nullable: 0
=head2 clientdatemodified
data_type: 'timestamp'
default_value: current_timestamp
is_nullable: 0
=head2 libraryid
data_type: 'int'
is_foreign_key: 1
is_nullable: 1
( run in 1.049 second using v1.01-cache-2.11-cpan-8dfa8b56332 )