1Mango::Bulk(3)        User Contributed Perl Documentation       Mango::Bulk(3)
2
3
4

NAME

6       Mango::Bulk - MongoDB bulk operations
7

SYNOPSIS

9         use Mango::Bulk;
10
11         my $bulk = Mango::Bulk->new(collection => $collection);
12         $bulk->insert({foo => 'bar'})->insert({foo => 'baz'})->execute;
13

DESCRIPTION

15       Mango::Bulk is a container for MongoDB bulk operations, all operations
16       will be automatically grouped so they don't exceed "max_bson_size" in
17       Mango.
18

ATTRIBUTES

20       Mango::Bulk implements the following attributes.
21
22   collection
23         my $collection = $bulk->collection;
24         $bulk          = $bulk->collection(Mango::Collection->new);
25
26       Mango::Collection object this bulk operation belongs to.
27
28   ordered
29         my $bool = $bulk->ordered;
30         $bulk    = $bulk->ordered($bool);
31
32       Bulk operations are ordered, defaults to a true value.
33

METHODS

35       Mango::Bulk inherits all methods from Mojo::Base and implements the
36       following new ones.
37
38   execute
39         my $results = $bulk->execute;
40
41       Execute bulk operations. You can also append a callback to perform
42       operation non-blocking.
43
44         $bulk->execute(sub {
45           my ($bulk, $err, $results) = @_;
46           ...
47         });
48         Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
49
50   find
51         $bulk = $bulk->find({foo => 'bar'});
52
53       Query for next update or remove operation.
54
55   insert
56         $bulk = $bulk->insert({foo => 'bar'});
57
58       Insert document.
59
60   remove
61         $bulk = $bulk->remove;
62
63       Remove multiple documents.
64
65   remove_one
66         $bulk = $bulk->remove_one;
67
68       Remove one document.
69
70   update
71         $bulk = $bulk->update({foo => 'bar'});
72
73       Update multiple documents.
74
75   update_one
76         $bulk = $bulk->update_one({foo => 'baz'});
77
78       Update one document.
79
80   upsert
81         $bulk = $bulk->upsert;
82
83       Next update operation will be an "upsert".
84

SEE ALSO

86       Mango, Mojolicious::Guides, <http://mojolicio.us>.
87
88
89
90perl v5.38.0                      2023-07-20                    Mango::Bulk(3)
Impressum