.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mango::GridFS 3pm" .TH Mango::GridFS 3pm "2020-06-05" "perl v5.30.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mango::GridFS \- GridFS .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Mango::GridFS; \& \& my $gridfs = Mango::GridFS\->new(db => $db); \& my $reader = $gridfs\->reader; \& my $writer = $gridfs\->writer; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Mango::GridFS is an interface for MongoDB GridFS access. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" Mango::GridFS implements the following attributes. .SS "chunks" .IX Subsection "chunks" .Vb 2 \& my $chunks = $gridfs\->chunks; \& $gridfs = $gridfs\->chunks(Mango::Collection\->new); .Ve .PP Mango::Collection object for \f(CW\*(C`chunks\*(C'\fR collection, defaults to one based on \&\*(L"prefix\*(R". .SS "db" .IX Subsection "db" .Vb 2 \& my $db = $gridfs\->db; \& $gridfs = $gridfs\->db(Mango::Database\->new); .Ve .PP Mango::Database object GridFS belongs to. .SS "files" .IX Subsection "files" .Vb 2 \& my $files = $gridfs\->files; \& $gridfs = $gridfs\->files(Mango::Collection\->new); .Ve .PP Mango::Collection object for \f(CW\*(C`files\*(C'\fR collection, defaults to one based on \&\*(L"prefix\*(R". .SS "prefix" .IX Subsection "prefix" .Vb 2 \& my $prefix = $gridfs\->prefix; \& $gridfs = $gridfs\->prefix(\*(Aqfoo\*(Aq); .Ve .PP Prefix for GridFS collections, defaults to \f(CW\*(C`fs\*(C'\fR. .SH "METHODS" .IX Header "METHODS" Mango::GridFS inherits all methods from Mojo::Base and implements the following new ones. .SS "delete" .IX Subsection "delete" .Vb 1 \& $gridfs\->delete($oid); .Ve .PP Delete file. You can also append a callback to perform operation non-blocking. .PP .Vb 5 \& $gridfs\->delete($oid => sub { \& my ($gridfs, $err) = @_; \& ... \& }); \& Mojo::IOLoop\->start unless Mojo::IOLoop\->is_running; .Ve .SS "find_version" .IX Subsection "find_version" .Vb 1 \& my $oid = $gridfs\->find_version(\*(Aqtest.txt\*(Aq, 1); .Ve .PP Find versions of files, positive numbers from \f(CW0\fR and upwards always point to a specific version, negative ones start with \f(CW\*(C`\-1\*(C'\fR for the most recently added version. You can also append a callback to perform operation non-blocking. .PP .Vb 5 \& $gridfs\->find_version((\*(Aqtest.txt\*(Aq, 1) => sub { \& my ($gridfs, $err, $oid) = @_; \& ... \& }); \& Mojo::IOLoop\->start unless Mojo::IOLoop\->is_running; .Ve .SS "list" .IX Subsection "list" .Vb 1 \& my $names = $gridfs\->list; .Ve .PP List files. You can also append a callback to perform operation non-blocking. .PP .Vb 5 \& $gridfs\->list(sub { \& my ($gridfs, $err, $names) = @_; \& ... \& }); \& Mojo::IOLoop\->start unless Mojo::IOLoop\->is_running; .Ve .SS "reader" .IX Subsection "reader" .Vb 1 \& my $reader = $gridfs\->reader; .Ve .PP Build Mango::GridFS::Reader object. .PP .Vb 3 \& # Read all data at once from newest version of file \& my $oid = $gridfs\->find_version(\*(Aqtest.txt\*(Aq, \-1); \& my $data = $gridfs\->reader\->open($oid)\->slurp; \& \& # Read all data in chunks from file \& my $reader = $gridfs\->reader\->open($oid); \& while (defined(my $chunk = $reader\->read)) { say "Chunk: $chunk" } .Ve .SS "writer" .IX Subsection "writer" .Vb 1 \& my $writer = $gridfs\->writer; .Ve .PP Build Mango::GridFS::Writer object. .PP .Vb 2 \& # Write all data at once to file with name \& my $oid = $gridfs\->writer\->filename(\*(Aqtest.txt\*(Aq)\->write(\*(AqHello!\*(Aq)\->close; \& \& # Write data in chunks to file \& my $writer = $gridfs\->writer; \& $writer\->write($_) for 1 .. 100; \& my $oid = $writer\->close; .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Mango, Mojolicious::Guides, .