The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mandel::Relationship::BelongsTo - A document is owned by another mongodb document

DESCRIPTION

Using DSL from Mandel::Document:

  package MyModel::Cat;
  use Mandel::Document;
  belongs_to owner => 'MyModel::Person';

Using object oriented interface:

  MyModel::Cat
    ->model
    ->relationship(belongs_to => owner => 'MyModel::Person');

Will add:

  $cat = MyModel::Cat->new->owner(\%args, $cb);
  $cat = MyModel::Cat->new->owner($person_obj, $cb);

  $person_obj = MyModel::Cat->new->owner(\%args);
  $person_obj = MyModel::Cat->new->owner($person_obj);
  $cat = MyModel::Cat->new->owner($bson_oid);

  $person = MyModel::Cat->new->owner;
  $self = MyModel::Cat->new->owner(sub { my($self, $err, $person) = @_; });

See also "relationship" in Mandel::Model.

ATTRIBUTES

foreign_field

The name of the field in this class which hold the "_id" to the related doc.

METHODS

monkey_patch

Add methods to "document_class" in Mandel::Relationship.

SEE ALSO

Mojolicious, Mango, Mandel::Relationship

AUTHOR

Jan Henning Thorsen - jhthorsen@cpan.org