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