| 1 | package Biblio::Zotero::DB::Schema::Result::TrashItemAttachment; | ||
| 2 | 13 | $Biblio::Zotero::DB::Schema::Result::TrashItemAttachment::VERSION = '0.004'; | |
| 3 | # TODO: document | ||
| 4 | |||
| 5 | 13 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 13 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 13 | ▶ | use base qw/Biblio::Zotero::DB::Schema::Result::ItemAttachment/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 13 | __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); | |
| 10 | 13 | __PACKAGE__->table('trashItemAttachments'); | |
| 11 | 13 | __PACKAGE__->result_source_instance->is_virtual(1); | |
| 12 | |||
| 13 | # NOTE: SQL | ||
| 14 | 13 | __PACKAGE__->result_source_instance->view_definition( | |
| 15 | q[ | ||
| 16 | SELECT * FROM itemAttachments me | ||
| 17 | WHERE ( | ||
| 18 | itemid IN ( SELECT me.itemid FROM deletedItems me ) | ||
| 19 | OR | ||
| 20 | sourceitemid IN ( SELECT me.itemid FROM deletedItems me ) | ||
| 21 | ) | ||
| 22 | ] | ||
| 23 | ); | ||
| 24 | # the above view_definition is the same as: | ||
| 25 | # ---------------------------------------- | ||
| 26 | # my $deleted = $schema->resultset('DeletedItem') | ||
| 27 | # ->get_column('itemid') | ||
| 28 | # ->as_query; | ||
| 29 | # $schema | ||
| 30 | # ->resultset('ItemAttachment') | ||
| 31 | # ->search( | ||
| 32 | # { -or => [ { itemid => { -in => $deleted } }, | ||
| 33 | # { sourceitemid => { -in => $deleted } } ] | ||
| 34 | # } | ||
| 35 | # )->as_query | ||
| 36 | # #### | ||
| 37 | |||
| 38 | 13 | 1; | |
| 39 | |||
| 40 | __END__ | ||