Filename | /usr/local/lib/perl/5.14.2/MongoDB/Collection.pm |
Statements | Executed 71 statements in 2.18ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
3 | 2 | 2 | 50µs | 348µs | find | MongoDB::Collection::
3 | 1 | 1 | 25µs | 40µs | _build_full_name | MongoDB::Collection::
2 | 1 | 1 | 25µs | 5.85s | find_one | MongoDB::Collection::
1 | 1 | 1 | 11µs | 44µs | BEGIN@29 | MongoDB::Collection::
1 | 1 | 1 | 10µs | 10µs | BEGIN@26 | MongoDB::Collection::
1 | 1 | 1 | 8µs | 2.87ms | BEGIN@27 | MongoDB::Collection::
1 | 1 | 1 | 8µs | 34µs | BEGIN@28 | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | AUTOLOAD | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | _make_safe | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | aggregate | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | batch_insert | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | count | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | drop | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | drop_index | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | drop_indexes | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | ensure_index | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | find_and_modify | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | get_collection | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | get_indexes | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | insert | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | query | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | remove | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | rename | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | save | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | to_index_string | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | update | MongoDB::Collection::
0 | 0 | 0 | 0s | 0s | validate | MongoDB::Collection::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # | ||||
2 | # Copyright 2009-2013 MongoDB, Inc. | ||||
3 | # | ||||
4 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||||
5 | # you may not use this file except in compliance with the License. | ||||
6 | # You may obtain a copy of the License at | ||||
7 | # | ||||
8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||
9 | # | ||||
10 | # Unless required by applicable law or agreed to in writing, software | ||||
11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
13 | # See the License for the specific language governing permissions and | ||||
14 | # limitations under the License. | ||||
15 | # | ||||
16 | |||||
17 | package MongoDB::Collection; | ||||
18 | { | ||||
19 | 2 | 1µs | $MongoDB::Collection::VERSION = '0.702.2'; | ||
20 | } | ||||
21 | |||||
22 | |||||
23 | # ABSTRACT: A MongoDB Collection | ||||
24 | |||||
25 | |||||
26 | 2 | 25µs | 1 | 10µs | # spent 10µs within MongoDB::Collection::BEGIN@26 which was called:
# once (10µs+0s) by MongoDB::BEGIN@31 at line 26 # spent 10µs making 1 call to MongoDB::Collection::BEGIN@26 |
27 | 2 | 47µs | 2 | 5.73ms | # spent 2.87ms (8µs+2.86) within MongoDB::Collection::BEGIN@27 which was called:
# once (8µs+2.86ms) by MongoDB::BEGIN@31 at line 27 # spent 2.87ms making 1 call to MongoDB::Collection::BEGIN@27
# spent 2.86ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:519] |
28 | 2 | 25µs | 2 | 60µs | # spent 34µs (8+26) within MongoDB::Collection::BEGIN@28 which was called:
# once (8µs+26µs) by MongoDB::BEGIN@31 at line 28 # spent 34µs making 1 call to MongoDB::Collection::BEGIN@28
# spent 26µs making 1 call to Exporter::import |
29 | 2 | 1.90ms | 2 | 50µs | # spent 44µs (11+33) within MongoDB::Collection::BEGIN@29 which was called:
# once (11µs+33µs) by MongoDB::BEGIN@31 at line 29 # spent 44µs making 1 call to MongoDB::Collection::BEGIN@29
# spent 6µs making 1 call to boolean::import |
30 | |||||
31 | 1 | 2µs | 1 | 1.55ms | has _database => ( # spent 1.55ms making 1 call to Moose::has |
32 | is => 'ro', | ||||
33 | isa => 'MongoDB::Database', | ||||
34 | required => 1, | ||||
35 | ); | ||||
36 | |||||
37 | |||||
38 | 1 | 2µs | 1 | 1.50ms | has name => ( # spent 1.50ms making 1 call to Moose::has |
39 | is => 'ro', | ||||
40 | isa => 'Str', | ||||
41 | required => 1, | ||||
42 | ); | ||||
43 | |||||
44 | 1 | 2µs | 1 | 2.07ms | has full_name => ( # spent 2.07ms making 1 call to Moose::has |
45 | is => 'ro', | ||||
46 | isa => 'Str', | ||||
47 | lazy => 1, | ||||
48 | builder => '_build_full_name', | ||||
49 | ); | ||||
50 | |||||
51 | # spent 40µs (25+14) within MongoDB::Collection::_build_full_name which was called 3 times, avg 13µs/call:
# 3 times (25µs+14µs) by MongoDB::Collection::full_name at line 12 of (eval 62)[Eval/Closure.pm:144], avg 13µs/call | ||||
52 | 12 | 20µs | my ($self) = @_; | ||
53 | 3 | 5µs | my $name = $self->name; # spent 5µs making 3 calls to MongoDB::Collection::name, avg 2µs/call | ||
54 | 6 | 9µs | my $db_name = $self->_database->name; # spent 6µs making 3 calls to MongoDB::Database::name, avg 2µs/call
# spent 3µs making 3 calls to MongoDB::Collection::_database, avg 1µs/call | ||
55 | return "${db_name}.${name}"; | ||||
56 | } | ||||
57 | |||||
58 | |||||
59 | sub AUTOLOAD { | ||||
60 | my $self = shift @_; | ||||
61 | our $AUTOLOAD; | ||||
62 | |||||
63 | my $coll = $AUTOLOAD; | ||||
64 | $coll =~ s/.*:://; | ||||
65 | |||||
66 | carp sprintf q{AUTOLOADed collection method names are deprecated and will be removed in a future release. Use $collection->get_collection( '%s' ) instead.}, $coll; | ||||
67 | |||||
68 | return $self->get_collection($coll); | ||||
69 | } | ||||
70 | |||||
71 | |||||
72 | sub get_collection { | ||||
73 | my $self = shift @_; | ||||
74 | my $coll = shift @_; | ||||
75 | |||||
76 | return $self->_database->get_collection($self->name.'.'.$coll); | ||||
77 | } | ||||
78 | |||||
79 | sub to_index_string { | ||||
80 | my $keys = shift; | ||||
81 | |||||
82 | my @name; | ||||
83 | if (ref $keys eq 'ARRAY') { | ||||
84 | @name = @$keys; | ||||
85 | } | ||||
86 | elsif (ref $keys eq 'HASH' ) { | ||||
87 | @name = %$keys | ||||
88 | } | ||||
89 | elsif (ref $keys eq 'Tie::IxHash') { | ||||
90 | my @ks = $keys->Keys; | ||||
91 | my @vs = $keys->Values; | ||||
92 | |||||
93 | for (my $i=0; $i<$keys->Length; $i++) { | ||||
94 | push @name, $ks[$i]; | ||||
95 | push @name, $vs[$i]; | ||||
96 | } | ||||
97 | } | ||||
98 | else { | ||||
99 | confess 'expected Tie::IxHash, hash, or array reference for keys'; | ||||
100 | } | ||||
101 | |||||
102 | return join("_", @name); | ||||
103 | } | ||||
104 | |||||
105 | |||||
106 | # spent 348µs (50+298) within MongoDB::Collection::find which was called 3 times, avg 116µs/call:
# 2 times (37µs+221µs) by MongoDB::Collection::find_one at line 144, avg 129µs/call
# once (14µs+77µs) by Mentat::Storage::Mongo::find_i at line 394 of Mentat/Storage/Mongo.pm | ||||
107 | 36 | 50µs | my ($self, $query, $attrs) = @_; | ||
108 | # old school options - these should be set with MongoDB::Cursor methods | ||||
109 | my ($limit, $skip, $sort_by) = @{ $attrs || {} }{qw/limit skip sort_by/}; | ||||
110 | |||||
111 | $limit ||= 0; | ||||
112 | $skip ||= 0; | ||||
113 | |||||
114 | my $q = $query || {}; | ||||
115 | 6 | 10µs | my $conn = $self->_database->_client; # spent 6µs making 3 calls to MongoDB::Database::_client, avg 2µs/call
# spent 5µs making 3 calls to MongoDB::Collection::_database, avg 2µs/call | ||
116 | 3 | 73µs | my $ns = $self->full_name; # spent 73µs making 3 calls to MongoDB::Collection::full_name, avg 24µs/call | ||
117 | 3 | 209µs | my $cursor = MongoDB::Cursor->new( # spent 209µs making 3 calls to MongoDB::Cursor::new, avg 70µs/call | ||
118 | _client => $conn, | ||||
119 | _ns => $ns, | ||||
120 | _query => $q, | ||||
121 | _limit => $limit, | ||||
122 | _skip => $skip | ||||
123 | ); | ||||
124 | |||||
125 | 3 | 6µs | $cursor->_init; # spent 6µs making 3 calls to MongoDB::Cursor::_init, avg 2µs/call | ||
126 | if ($sort_by) { | ||||
127 | $cursor->sort($sort_by); | ||||
128 | } | ||||
129 | return $cursor; | ||||
130 | } | ||||
131 | |||||
132 | sub query { | ||||
133 | my ($self, $query, $attrs) = @_; | ||||
134 | |||||
135 | return $self->find($query, $attrs); | ||||
136 | } | ||||
137 | |||||
138 | |||||
139 | # spent 5.85s (25µs+5.85) within MongoDB::Collection::find_one which was called 2 times, avg 2.92s/call:
# 2 times (25µs+5.85s) by MongoDB::Database::run_command at line 109 of MongoDB/Database.pm, avg 2.92s/call | ||||
140 | 8 | 18µs | my ($self, $query, $fields) = @_; | ||
141 | $query ||= {}; | ||||
142 | $fields ||= {}; | ||||
143 | |||||
144 | 1 | 71µs | 19 | 11.7s | return $self->find($query)->limit(-1)->fields($fields)->next; # spent 5.85s making 2 calls to MongoDB::Cursor::next, avg 2.92s/call
# spent 5.85s making 2 calls to MongoDB::Cursor::_do_query, avg 2.92s/call
# spent 257µs making 2 calls to MongoDB::Collection::find, avg 129µs/call
# spent 42µs making 2 calls to MongoDB::Cursor::limit, avg 21µs/call
# spent 34µs making 2 calls to MongoDB::Cursor::_dt_type, avg 17µs/call
# spent 26µs making 2 calls to MongoDB::Cursor::fields, avg 13µs/call
# spent 20µs making 2 calls to MongoDB::Cursor::_inflate_dbrefs, avg 10µs/call
# spent 5µs making 2 calls to MongoDB::Cursor::_limit, avg 3µs/call
# spent 2µs making 1 call to boolean::false
# spent 2µs making 2 calls to MongoDB::Cursor::_client, avg 1µs/call |
145 | } | ||||
146 | |||||
147 | |||||
148 | sub insert { | ||||
149 | my ($self, $object, $options) = @_; | ||||
150 | my ($id) = $self->batch_insert([$object], $options); | ||||
151 | |||||
152 | return $id; | ||||
153 | } | ||||
154 | |||||
155 | |||||
156 | sub batch_insert { | ||||
157 | my ($self, $object, $options) = @_; | ||||
158 | confess 'not an array reference' unless ref $object eq 'ARRAY'; | ||||
159 | |||||
160 | my $add_ids = 1; | ||||
161 | if ($options->{'no_ids'}) { | ||||
162 | $add_ids = 0; | ||||
163 | } | ||||
164 | |||||
165 | my $conn = $self->_database->_client; | ||||
166 | my $ns = $self->full_name; | ||||
167 | |||||
168 | my ($insert, $ids) = MongoDB::write_insert($ns, $object, $add_ids); | ||||
169 | if (length($insert) > $conn->max_bson_size) { | ||||
170 | Carp::croak("insert is too large: ".length($insert)." max: ".$conn->max_bson_size); | ||||
171 | return 0; | ||||
172 | } | ||||
173 | |||||
174 | if ( ( defined($options) && $options->{safe} ) or $conn->_w_want_safe ) { | ||||
175 | my $ok = $self->_make_safe($insert); | ||||
176 | |||||
177 | if (!$ok) { | ||||
178 | return 0; | ||||
179 | } | ||||
180 | } | ||||
181 | else { | ||||
182 | $conn->send($insert); | ||||
183 | } | ||||
184 | |||||
185 | return $ids ? @$ids : $ids; | ||||
186 | } | ||||
187 | |||||
188 | |||||
189 | sub update { | ||||
190 | my ($self, $query, $object, $opts) = @_; | ||||
191 | |||||
192 | # there used to be one option: upsert=0/1 | ||||
193 | # now there are two, there will probably be | ||||
194 | # more in the future. So, to support old code, | ||||
195 | # passing "1" will still be supported, but not | ||||
196 | # documentd, so we can phase that out eventually. | ||||
197 | # | ||||
198 | # The preferred way of passing options will be a | ||||
199 | # hash of {optname=>value, ...} | ||||
200 | my $flags = 0; | ||||
201 | if ($opts && ref $opts eq 'HASH') { | ||||
202 | $flags |= $opts->{'upsert'} << 0 | ||||
203 | if exists $opts->{'upsert'}; | ||||
204 | $flags |= $opts->{'multiple'} << 1 | ||||
205 | if exists $opts->{'multiple'}; | ||||
206 | } | ||||
207 | else { | ||||
208 | $flags = !(!$opts); | ||||
209 | } | ||||
210 | |||||
211 | my $conn = $self->_database->_client; | ||||
212 | my $ns = $self->full_name; | ||||
213 | |||||
214 | my $update = MongoDB::write_update($ns, $query, $object, $flags); | ||||
215 | if ($opts->{safe} or $conn->_w_want_safe ) { | ||||
216 | return $self->_make_safe($update); | ||||
217 | } | ||||
218 | |||||
219 | if ($conn->send($update) == -1) { | ||||
220 | $conn->connect; | ||||
221 | die("can't get db response, not connected"); | ||||
222 | } | ||||
223 | |||||
224 | return 1; | ||||
225 | } | ||||
226 | |||||
227 | |||||
228 | sub find_and_modify { | ||||
229 | my ( $self, $opts ) = @_; | ||||
230 | |||||
231 | my $conn = $self->_database->_client; | ||||
232 | my $db = $self->_database; | ||||
233 | |||||
234 | my $result = $db->run_command( [ findAndModify => $self->name, %$opts ] ); | ||||
235 | |||||
236 | if ( not $result->{ok} ) { | ||||
237 | return if ( $result->{errmsg} eq 'No matching object found' ); | ||||
238 | } | ||||
239 | |||||
240 | return $result->{value}; | ||||
241 | } | ||||
242 | |||||
243 | |||||
244 | sub aggregate { | ||||
245 | my ( $self, $pipeline ) = @_; | ||||
246 | |||||
247 | my $db = $self->_database; | ||||
248 | |||||
249 | my $result = $db->run_command( [ aggregate => $self->name, pipeline => $pipeline ] ); | ||||
250 | |||||
251 | # TODO: handle errors? | ||||
252 | |||||
253 | return $result->{result}; | ||||
254 | } | ||||
255 | |||||
256 | |||||
257 | sub rename { | ||||
258 | my ($self, $collectionname) = @_; | ||||
259 | |||||
260 | my $conn = $self->_database->_client; | ||||
261 | my $database = $conn->get_database( 'admin' ); | ||||
262 | my $fullname = $self->full_name; | ||||
263 | |||||
264 | my ($db, @collection_bits) = split(/\./, $fullname); | ||||
265 | my $collection = join('.', @collection_bits); | ||||
266 | my $obj = $database->run_command([ 'renameCollection' => "$db.$collection", 'to' => "$db.$collectionname" ]); | ||||
267 | |||||
268 | if(ref($obj) eq "HASH"){ | ||||
269 | return $conn->get_database( $db )->get_collection( $collectionname ); | ||||
270 | } | ||||
271 | else { | ||||
272 | die $obj; | ||||
273 | } | ||||
274 | } | ||||
275 | |||||
276 | |||||
277 | sub remove { | ||||
278 | my ($self, $query, $options) = @_; | ||||
279 | |||||
280 | my $conn = $self->_database->_client; | ||||
281 | |||||
282 | my ($just_one, $safe); | ||||
283 | if (defined $options && ref $options eq 'HASH') { | ||||
284 | $just_one = exists $options->{just_one} ? $options->{just_one} : 0; | ||||
285 | $safe = $options->{safe} or $conn->_w_want_safe; | ||||
286 | } | ||||
287 | else { | ||||
288 | $just_one = $options || 0; | ||||
289 | } | ||||
290 | |||||
291 | my $ns = $self->full_name; | ||||
292 | $query ||= {}; | ||||
293 | |||||
294 | my $remove = MongoDB::write_remove($ns, $query, $just_one); | ||||
295 | if ($safe) { | ||||
296 | return $self->_make_safe($remove); | ||||
297 | } | ||||
298 | |||||
299 | if ($conn->send($remove) == -1) { | ||||
300 | $conn->connect; | ||||
301 | die("can't get db response, not connected"); | ||||
302 | } | ||||
303 | |||||
304 | return 1; | ||||
305 | } | ||||
306 | |||||
307 | |||||
308 | sub ensure_index { | ||||
309 | my ($self, $keys, $options, $garbage) = @_; | ||||
310 | my $ns = $self->full_name; | ||||
311 | |||||
312 | # we need to use the crappy old api if... | ||||
313 | # - $options isn't a hash, it's a string like "ascending" | ||||
314 | # - $keys is a one-element array: [foo] | ||||
315 | # - $keys is an array with more than one element and the second | ||||
316 | # element isn't a direction (or at least a good one) | ||||
317 | # - Tie::IxHash has values like "ascending" | ||||
318 | if (($options && ref $options ne 'HASH') || | ||||
319 | (ref $keys eq 'ARRAY' && | ||||
320 | ($#$keys == 0 || $#$keys >= 1 && !($keys->[1] =~ /-?1/))) || | ||||
321 | (ref $keys eq 'Tie::IxHash' && $keys->[2][0] =~ /(de|a)scending/)) { | ||||
322 | Carp::croak("you're using the old ensure_index format, please upgrade"); | ||||
323 | } | ||||
324 | |||||
325 | $keys = Tie::IxHash->new(@$keys) if ref $keys eq 'ARRAY'; | ||||
326 | my $obj = Tie::IxHash->new("ns" => $ns, "key" => $keys); | ||||
327 | |||||
328 | if (exists $options->{name}) { | ||||
329 | $obj->Push("name" => $options->{name}); | ||||
330 | } | ||||
331 | else { | ||||
332 | $obj->Push("name" => MongoDB::Collection::to_index_string($keys)); | ||||
333 | } | ||||
334 | |||||
335 | foreach ("unique", "drop_dups", "background", "sparse") { | ||||
336 | if (exists $options->{$_}) { | ||||
337 | $obj->Push("$_" => ($options->{$_} ? boolean::true : boolean::false)); | ||||
338 | } | ||||
339 | } | ||||
340 | $options->{'no_ids'} = 1; | ||||
341 | |||||
342 | if (exists $options->{expire_after_seconds}) { | ||||
343 | $obj->Push("expireAfterSeconds" => int($options->{expire_after_seconds})); | ||||
344 | } | ||||
345 | |||||
346 | my ($db, $coll) = $ns =~ m/^([^\.]+)\.(.*)/; | ||||
347 | |||||
348 | my $indexes = $self->_database->get_collection("system.indexes"); | ||||
349 | return $indexes->insert($obj, $options); | ||||
350 | } | ||||
351 | |||||
352 | |||||
353 | sub _make_safe { | ||||
354 | my ($self, $req) = @_; | ||||
355 | my $conn = $self->_database->_client; | ||||
356 | my $db = $self->_database->name; | ||||
357 | |||||
358 | my $last_error = Tie::IxHash->new(getlasterror => 1, w => $conn->w, wtimeout => $conn->wtimeout, j => $conn->j); | ||||
359 | my ($query, $info) = MongoDB::write_query($db.'.$cmd', 0, 0, -1, $last_error); | ||||
360 | |||||
361 | $conn->send("$req$query"); | ||||
362 | |||||
363 | my $cursor = MongoDB::Cursor->new(_ns => $info->{ns}, _client => $conn, _query => {}); | ||||
364 | $cursor->_init; | ||||
365 | $cursor->_request_id($info->{'request_id'}); | ||||
366 | |||||
367 | $conn->recv($cursor); | ||||
368 | $cursor->started_iterating(1); | ||||
369 | |||||
370 | my $ok = $cursor->next(); | ||||
371 | |||||
372 | # $ok->{ok} is 1 if err is set | ||||
373 | Carp::croak $ok->{err} if $ok->{err}; | ||||
374 | # $ok->{ok} == 0 is still an error | ||||
375 | if (!$ok->{ok}) { | ||||
376 | Carp::croak $ok->{errmsg}; | ||||
377 | } | ||||
378 | |||||
379 | return $ok; | ||||
380 | } | ||||
381 | |||||
382 | sub save { | ||||
383 | my ($self, $doc, $options) = @_; | ||||
384 | |||||
385 | if (exists $doc->{"_id"}) { | ||||
386 | |||||
387 | if (!$options || !ref $options eq 'HASH') { | ||||
388 | $options = {"upsert" => boolean::true}; | ||||
389 | } | ||||
390 | else { | ||||
391 | $options->{'upsert'} = boolean::true; | ||||
392 | } | ||||
393 | |||||
394 | return $self->update({"_id" => $doc->{"_id"}}, $doc, $options); | ||||
395 | } | ||||
396 | else { | ||||
397 | return $self->insert($doc, $options); | ||||
398 | } | ||||
399 | } | ||||
400 | |||||
401 | |||||
402 | sub count { | ||||
403 | my ($self, $query) = @_; | ||||
404 | $query ||= {}; | ||||
405 | |||||
406 | my $obj; | ||||
407 | eval { | ||||
408 | $obj = $self->_database->run_command([ | ||||
409 | count => $self->name, | ||||
410 | query => $query, | ||||
411 | ]); | ||||
412 | }; | ||||
413 | |||||
414 | # if there was an error, check if it was the "ns missing" one that means the | ||||
415 | # collection hasn't been created or a real error. | ||||
416 | if ($@) { | ||||
417 | # if the request timed out, $obj might not be initialized | ||||
418 | if ($obj && $obj =~ m/^ns missing/) { | ||||
419 | return 0; | ||||
420 | } | ||||
421 | else { | ||||
422 | die $@; | ||||
423 | } | ||||
424 | } | ||||
425 | |||||
426 | return $obj->{n}; | ||||
427 | } | ||||
428 | |||||
429 | |||||
430 | sub validate { | ||||
431 | my ($self, $scan_data) = @_; | ||||
432 | $scan_data = 0 unless defined $scan_data; | ||||
433 | my $obj = $self->_database->run_command({ validate => $self->name }); | ||||
434 | } | ||||
435 | |||||
436 | |||||
437 | sub drop_indexes { | ||||
438 | my ($self) = @_; | ||||
439 | return $self->drop_index('*'); | ||||
440 | } | ||||
441 | |||||
442 | |||||
443 | sub drop_index { | ||||
444 | my ($self, $index_name) = @_; | ||||
445 | return $self->_database->run_command([ | ||||
446 | deleteIndexes => $self->name, | ||||
447 | index => $index_name, | ||||
448 | ]); | ||||
449 | } | ||||
450 | |||||
451 | |||||
452 | sub get_indexes { | ||||
453 | my ($self) = @_; | ||||
454 | return $self->_database->get_collection('system.indexes')->query({ | ||||
455 | ns => $self->full_name, | ||||
456 | })->all; | ||||
457 | } | ||||
458 | |||||
459 | sub drop { | ||||
460 | my ($self) = @_; | ||||
461 | $self->_database->run_command({ drop => $self->name }); | ||||
462 | return; | ||||
463 | } | ||||
464 | |||||
- - | |||||
467 | 1 | 2µs | 2 | 3.44ms | __PACKAGE__->meta->make_immutable; # spent 3.43ms making 1 call to Class::MOP::Class::make_immutable
# spent 13µs making 1 call to MongoDB::Collection::meta |
468 | |||||
469 | 1 | 8µs | 1; | ||
470 | |||||
471 | __END__ |