Skip to main content
Rollback to Revision 3
Source Link
Ludisposed
  • 11.6k
  • 2
  • 39
  • 91

MongoDB Perl Wrapper to wrap code

-- Delete -- I'm trying to create a custom "mongodb perl wrapper". adasdadI created the following perl module, which local on my machine runs. My questions to the community are:

  • Would you create the module different?
  • Do you have improvements or adaptations to create the module better?

ad a sda sd asd as d as das d asdasdasdasdCode:

package MyMongo;

use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use MongoDB;

$VERSION     = 1.00;
@ISA         = qw(Exporter);
@EXPORT      = qw();
@EXPORT_OK   = qw();
%EXPORT_TAGS = ( DEFAULT => [qw()],
                 Both    => [qw()]);

sub new {
    my ($class, $args) = @_;
    my $self = {
        host     => $args->{host} || 'localhost',       
        port     => $args->{port} || '27017',
        database => $args->{database} || '',
        connection => $class->_set_connection(),
    };
    return bless $self, $class;
}

sub _set_connection {
    my $self = shift;
    my $client = MongoDB->connect('mongodb://localhost');
    return $client;
}

sub get_database_names {
    # Lists all databases on the mongo server
    my $self = shift;
    return  $self->{connection}->database_names;
}

sub get_database {
    # Returns a MongoDB::Database instance for database with the given $name
    my ($self, $dbname) = @_;
    return $self->{connection}->get_database($dbname);
}

sub authenticate {
    my ($self, $args) = @_;
    $self = {
        dbname => $args->{dbname},
        user => $args->{user},
        password => $args->{password}
    };
    $self->{connection}->authenticate($self->{dbname}, $self->{user}, $self->{password});
}
1;

Wrapper to wrap code

-- Delete -- adasdad

ad a sda sd asd as d as das d asdasdasdasd

MongoDB Perl Wrapper

I'm trying to create a custom "mongodb perl wrapper". I created the following perl module, which local on my machine runs. My questions to the community are:

  • Would you create the module different?
  • Do you have improvements or adaptations to create the module better?

Code:

package MyMongo;

use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use MongoDB;

$VERSION     = 1.00;
@ISA         = qw(Exporter);
@EXPORT      = qw();
@EXPORT_OK   = qw();
%EXPORT_TAGS = ( DEFAULT => [qw()],
                 Both    => [qw()]);

sub new {
    my ($class, $args) = @_;
    my $self = {
        host     => $args->{host} || 'localhost',       
        port     => $args->{port} || '27017',
        database => $args->{database} || '',
        connection => $class->_set_connection(),
    };
    return bless $self, $class;
}

sub _set_connection {
    my $self = shift;
    my $client = MongoDB->connect('mongodb://localhost');
    return $client;
}

sub get_database_names {
    # Lists all databases on the mongo server
    my $self = shift;
    return  $self->{connection}->database_names;
}

sub get_database {
    # Returns a MongoDB::Database instance for database with the given $name
    my ($self, $dbname) = @_;
    return $self->{connection}->get_database($dbname);
}

sub authenticate {
    my ($self, $args) = @_;
    $self = {
        dbname => $args->{dbname},
        user => $args->{user},
        password => $args->{password}
    };
    $self->{connection}->authenticate($self->{dbname}, $self->{user}, $self->{password});
}
1;
deleted 1776 characters in body; edited title
Source Link
Patrick85
  • 491
  • 3
  • 10

MongoDB Perl Wrapper to wrap code

I'm trying to create a custom "mongodb perl wrapper". I created the following perl module, which local on my machine runs.-- Delete -- My questions to the community are:adasdad

  • Would you create the module different?
  • Do you have improvements or adaptations to create the module better?

Code:ad a sda sd asd as d as das d asdasdasdasd

package MyMongo;

use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use MongoDB;

$VERSION     = 1.00;
@ISA         = qw(Exporter);
@EXPORT      = qw();
@EXPORT_OK   = qw();
%EXPORT_TAGS = ( DEFAULT => [qw()],
                 Both    => [qw()]);

sub new {
    my ($class, $args) = @_;
    my $self = {
        host     => $args->{host} || 'localhost',       
        port     => $args->{port} || '27017',
        database => $args->{database} || '',
        connection => $class->_set_connection(),
    };
    return bless $self, $class;
}

sub _set_connection {
    my $self = shift;
    my $client = MongoDB->connect('mongodb://localhost');
    return $client;
}

sub get_database_names {
    # Lists all databases on the mongo server
    my $self = shift;
    return  $self->{connection}->database_names;
}

sub get_database {
    # Returns a MongoDB::Database instance for database with the given $name
    my ($self, $dbname) = @_;
    return $self->{connection}->get_database($dbname);
}

sub authenticate {
    my ($self, $args) = @_;
    $self = {
        dbname => $args->{dbname},
        user => $args->{user},
        password => $args->{password}
    };
    $self->{connection}->authenticate($self->{dbname}, $self->{user}, $self->{password});
}
1;

MongoDB Perl Wrapper

I'm trying to create a custom "mongodb perl wrapper". I created the following perl module, which local on my machine runs. My questions to the community are:

  • Would you create the module different?
  • Do you have improvements or adaptations to create the module better?

Code:

package MyMongo;

use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use MongoDB;

$VERSION     = 1.00;
@ISA         = qw(Exporter);
@EXPORT      = qw();
@EXPORT_OK   = qw();
%EXPORT_TAGS = ( DEFAULT => [qw()],
                 Both    => [qw()]);

sub new {
    my ($class, $args) = @_;
    my $self = {
        host     => $args->{host} || 'localhost',       
        port     => $args->{port} || '27017',
        database => $args->{database} || '',
        connection => $class->_set_connection(),
    };
    return bless $self, $class;
}

sub _set_connection {
    my $self = shift;
    my $client = MongoDB->connect('mongodb://localhost');
    return $client;
}

sub get_database_names {
    # Lists all databases on the mongo server
    my $self = shift;
    return  $self->{connection}->database_names;
}

sub get_database {
    # Returns a MongoDB::Database instance for database with the given $name
    my ($self, $dbname) = @_;
    return $self->{connection}->get_database($dbname);
}

sub authenticate {
    my ($self, $args) = @_;
    $self = {
        dbname => $args->{dbname},
        user => $args->{user},
        password => $args->{password}
    };
    $self->{connection}->authenticate($self->{dbname}, $self->{user}, $self->{password});
}
1;

Wrapper to wrap code

-- Delete -- adasdad

ad a sda sd asd as d as das d asdasdasdasd

deleted 14 characters in body; edited title
Source Link
Phrancis
  • 20.4k
  • 6
  • 68
  • 154

mongodb MongoDB Perl Wrapper

I'm trying to create a custom "mongodb perl wrapper". I created the following perl module, which local on my machine runs. My questions to the community are:

  • Would you create the module different?
  • Do you have improvements or adaptations to create the module better?

the perl module

Code:

package MyMongo;

use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use MongoDB;

$VERSION     = 1.00;
@ISA         = qw(Exporter);
@EXPORT      = qw();
@EXPORT_OK   = qw();
%EXPORT_TAGS = ( DEFAULT => [qw()],
                 Both    => [qw()]);

sub new {
    my ($class, $args) = @_;
    my $self = {
        host     => $args->{host} || 'localhost',       
        port     => $args->{port} || '27017',
        database => $args->{database} || '',
        connection => $class->_set_connection(),
    };
    return bless $self, $class;
}

sub _set_connection {
    my $self = shift;
    my $client = MongoDB->connect('mongodb://localhost');
    return $client;
}

sub get_database_names {
    # Lists all databases on the mongo server
    my $self = shift;
    return  $self->{connection}->database_names;
}

sub get_database {
    # Returns a MongoDB::Database instance for database with the given $name
    my ($self, $dbname) = @_;
    return $self->{connection}->get_database($dbname);
}

sub authenticate {
    my ($self, $args) = @_;
    $self = {
        dbname => $args->{dbname},
        user => $args->{user},
        password => $args->{password}
    };
    $self->{connection}->authenticate($self->{dbname}, $self->{user}, $self->{password});
}
1;

mongodb Perl Wrapper

I'm trying to create a custom "mongodb perl wrapper". I created the following perl module, which local on my machine runs. My questions to the community are:

  • Would you create the module different?
  • Do you have improvements or adaptations to create the module better?

the perl module

package MyMongo;

use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use MongoDB;

$VERSION     = 1.00;
@ISA         = qw(Exporter);
@EXPORT      = qw();
@EXPORT_OK   = qw();
%EXPORT_TAGS = ( DEFAULT => [qw()],
                 Both    => [qw()]);

sub new {
    my ($class, $args) = @_;
    my $self = {
        host     => $args->{host} || 'localhost',       
        port     => $args->{port} || '27017',
        database => $args->{database} || '',
        connection => $class->_set_connection(),
    };
    return bless $self, $class;
}

sub _set_connection {
    my $self = shift;
    my $client = MongoDB->connect('mongodb://localhost');
    return $client;
}

sub get_database_names {
    # Lists all databases on the mongo server
    my $self = shift;
    return  $self->{connection}->database_names;
}

sub get_database {
    # Returns a MongoDB::Database instance for database with the given $name
    my ($self, $dbname) = @_;
    return $self->{connection}->get_database($dbname);
}

sub authenticate {
    my ($self, $args) = @_;
    $self = {
        dbname => $args->{dbname},
        user => $args->{user},
        password => $args->{password}
    };
    $self->{connection}->authenticate($self->{dbname}, $self->{user}, $self->{password});
}
1;

MongoDB Perl Wrapper

I'm trying to create a custom "mongodb perl wrapper". I created the following perl module, which local on my machine runs. My questions to the community are:

  • Would you create the module different?
  • Do you have improvements or adaptations to create the module better?

Code:

package MyMongo;

use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use MongoDB;

$VERSION     = 1.00;
@ISA         = qw(Exporter);
@EXPORT      = qw();
@EXPORT_OK   = qw();
%EXPORT_TAGS = ( DEFAULT => [qw()],
                 Both    => [qw()]);

sub new {
    my ($class, $args) = @_;
    my $self = {
        host     => $args->{host} || 'localhost',       
        port     => $args->{port} || '27017',
        database => $args->{database} || '',
        connection => $class->_set_connection(),
    };
    return bless $self, $class;
}

sub _set_connection {
    my $self = shift;
    my $client = MongoDB->connect('mongodb://localhost');
    return $client;
}

sub get_database_names {
    # Lists all databases on the mongo server
    my $self = shift;
    return  $self->{connection}->database_names;
}

sub get_database {
    # Returns a MongoDB::Database instance for database with the given $name
    my ($self, $dbname) = @_;
    return $self->{connection}->get_database($dbname);
}

sub authenticate {
    my ($self, $args) = @_;
    $self = {
        dbname => $args->{dbname},
        user => $args->{user},
        password => $args->{password}
    };
    $self->{connection}->authenticate($self->{dbname}, $self->{user}, $self->{password});
}
1;
Source Link
Patrick85
  • 491
  • 3
  • 10
Loading