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
Mongoose::Class(3) User Contributed Perl Documentation Mongoose::Class(3)

Mongoose::Class - sugary Mongoose-oriented replacement for Moose

    package MySchema::Person;
    use Mongoose::Class; # uses Moose for you
    with 'Mongoose::Document';

    has 'name'          => ( is => 'rw', isa => 'Str' );
    has_many 'siblings' => ( is => 'rw', isa => 'Person' );
    belongs_to 'club'   => ( is => 'rw', isa => 'Club' );
    has_one 'father'    => ( is => 'rw', isa => 'Person' );

This is very much a work-in-progress.

Basically, this module adds some sugar into your Mongoose Document class by defining some stand-in replacements for Moose's own "has".

    has_many
    has_one
    belongs_to

The idea: fewer keystrokes and improved readability by self-documenting your class.

Wrapper around Moose's own "has", but allows for a shorter syntax:

    has_one 'name';            # isa=>'Any', is=>'rw' added
    has_one 'age' => 'Num';    # is=>'rw' added
    has_one 'age' => 'Num', default=>99;

It's the same as using "has_one" from above. It exists to improve your code expressiveness.

Wraps the defined relationship with another class using "Mongoose::Join".

This:

    has_many 'employees' => ( isa=>'Employee' );

    # or

    has_many 'employees' => 'Employee';

Becomes this:

    has 'employees' => (
        is      => 'ro',
        isa     => 'Mongoose::Join[Employee]',
        default => sub { Mongoose::Join->new( with_class=>'Employee' ) }
    );
2018-10-08 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.