line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Cmd::delete; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
132301
|
use Catmandu::Sane; |
|
14
|
|
|
|
|
51
|
|
|
14
|
|
|
|
|
92
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
14
|
|
|
14
|
|
108
|
use parent 'Catmandu::Cmd'; |
|
14
|
|
|
|
|
52
|
|
|
14
|
|
|
|
|
76
|
|
8
|
14
|
|
|
14
|
|
1027
|
use Catmandu; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
80
|
|
9
|
14
|
|
|
14
|
|
3084
|
use Catmandu::Util qw(check_able); |
|
14
|
|
|
|
|
39
|
|
|
14
|
|
|
|
|
741
|
|
10
|
14
|
|
|
14
|
|
90
|
use namespace::clean; |
|
14
|
|
|
|
|
33
|
|
|
14
|
|
|
|
|
78
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub command_opt_spec { |
13
|
1
|
|
|
1
|
1
|
17
|
(["cql-query|q=s", ""], ["query=s", ""], ["id=s@", ""],); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub command { |
17
|
1
|
|
|
1
|
1
|
4
|
my ($self, $opts, $args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
7
|
my ($from_args, $from_opts) = $self->_parse_options($args); |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
4
|
my $from_bag = delete $from_opts->{bag}; |
22
|
1
|
|
|
|
|
9
|
my $from = Catmandu->store($from_args->[0], $from_opts)->bag($from_bag); |
23
|
1
|
50
|
33
|
|
|
7
|
if ($opts->id) { |
|
|
50
|
|
|
|
|
|
24
|
0
|
|
|
|
|
0
|
$from->delete($_) for @{$opts->id}; |
|
0
|
|
|
|
|
0
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ($opts->query // $opts->cql_query) { |
27
|
0
|
|
|
|
|
0
|
check_able($from, 'delete_by_query'); |
28
|
0
|
|
|
|
|
0
|
$from->delete_by_query( |
29
|
|
|
|
|
|
|
cql_query => $opts->cql_query, |
30
|
|
|
|
|
|
|
query => $opts->query, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
1
|
|
|
|
|
37
|
$from->delete_all; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
19
|
$from->commit; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Catmandu::Cmd::delete - delete items from a store |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 EXAMPLES |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
catmandu delete <STORE> <OPTIONS> |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# delete items with matching _id |
56
|
|
|
|
|
|
|
catmandu delete ElasticSearch --index-name items --bag book \ |
57
|
|
|
|
|
|
|
--id 1234 --id 2345 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# delete items matching the query |
60
|
|
|
|
|
|
|
catmandu delete ElasticSearch --index-name items --bag book \ |
61
|
|
|
|
|
|
|
--query 'title:"My Rabbit"' |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# delete all items |
64
|
|
|
|
|
|
|
catmandu delete ElasticSearch --index-name items --bag book |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
catmandu help store ElasticSearch |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |