GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Mango::GridFS(3) User Contributed Perl Documentation Mango::GridFS(3)

Mango::GridFS - GridFS

  use Mango::GridFS;

  my $gridfs = Mango::GridFS->new(db => $db);
  my $reader = $gridfs->reader;
  my $writer = $gridfs->writer;

Mango::GridFS is an interface for MongoDB GridFS access.

Mango::GridFS implements the following attributes.

  my $chunks = $gridfs->chunks;
  $gridfs    = $gridfs->chunks(Mango::Collection->new);

Mango::Collection object for "chunks" collection, defaults to one based on "prefix".

  my $db  = $gridfs->db;
  $gridfs = $gridfs->db(Mango::Database->new);

Mango::Database object GridFS belongs to.

  my $files = $gridfs->files;
  $gridfs   = $gridfs->files(Mango::Collection->new);

Mango::Collection object for "files" collection, defaults to one based on "prefix".

  my $prefix = $gridfs->prefix;
  $gridfs    = $gridfs->prefix('foo');

Prefix for GridFS collections, defaults to "fs".

Mango::GridFS inherits all methods from Mojo::Base and implements the following new ones.

  $gridfs->delete($oid);

Delete file. You can also append a callback to perform operation non-blocking.

  $gridfs->delete($oid => sub {
    my ($gridfs, $err) = @_;
    ...
  });
  Mojo::IOLoop->start unless Mojo::IOLoop->is_running;

  my $oid = $gridfs->find_version('test.txt', 1);

Find versions of files, positive numbers from 0 and upwards always point to a specific version, negative ones start with "-1" for the most recently added version. You can also append a callback to perform operation non-blocking.

  $gridfs->find_version(('test.txt', 1) => sub {
    my ($gridfs, $err, $oid) = @_;
    ...
  });
  Mojo::IOLoop->start unless Mojo::IOLoop->is_running;

  my $names = $gridfs->list;

List files. You can also append a callback to perform operation non-blocking.

  $gridfs->list(sub {
    my ($gridfs, $err, $names) = @_;
    ...
  });
  Mojo::IOLoop->start unless Mojo::IOLoop->is_running;

  my $reader = $gridfs->reader;

Build Mango::GridFS::Reader object.

  # Read all data at once from newest version of file
  my $oid  = $gridfs->find_version('test.txt', -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" }

  my $writer = $gridfs->writer;

Build Mango::GridFS::Writer object.

  # Write all data at once to file with name
  my $oid = $gridfs->writer->filename('test.txt')->write('Hello!')->close;

  # Write data in chunks to file
  my $writer = $gridfs->writer;
  $writer->write($_) for 1 .. 100;
  my $oid = $writer->close;

Mango, Mojolicious::Guides, <http://mojolicio.us>.
2018-03-17 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.