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


Manual Reference Pages  -  MANGO::GRIDFS (3)

.ds Aq ’

NAME

Mango::GridFS - GridFS

CONTENTS

SYNOPSIS



  use Mango::GridFS;

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



DESCRIPTION

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

ATTRIBUTES

Mango::GridFS implements the following attributes.

    chunks



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



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

    db



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



Mango::Database object GridFS belongs to.

    files



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



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

    prefix



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



Prefix for GridFS collections, defaults to fs.

METHODS

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

    delete



  $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;



    find_version



  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;



    list



  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;



    reader



  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" }



    writer



  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;



SEE ALSO

Mango, Mojolicious::Guides, <http://mojolicio.us>.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MANGO::GRIDFS (3) 2015-12-02

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