MongoDBx-Class
view release on metacpan or search on metacpan
lib/MongoDBx/Class/Document.pm view on Meta::CPAN
return $self->_collection->update({ _id => $self->_id }, $self->_connection->collapse($doc), $_[1]);
}
}
=head2 delete()
=head2 remove()
Both methods are equivalent. They are shortcut methods for invoking the
collection's C<remove()> method on this document only. So, umm, they remove
the document. But note that this operation does not cascade, so documents
which are considered dependant on this document (such as those that reference
it with C<belongs_to>) will not be removed too.
=cut
sub delete {
my $self = shift;
$self->_collection->remove({ _id => $self->_id });
}
lib/MongoDBx/Class/Tutorial.pod view on Meta::CPAN
Removing documents with MongoDBx::Class is very easy. Having the document
object, simply call:
$novel->remove;
Or:
$novel->delete;
And this novel document will be removed from the database. Note, however,
that the delete operation does not cascade, so only the novel document is
deleted. The synopsis and reviews are not deleted, and you have to do so
manually.
You can still use the original C<remove()> method on collections, now mostly
to remove multiple documents:
$db->get_collection('reviews')->remove({ 'novel.$id' => $novel->_id }); # removes are by default multiple
=head1 FAQ
( run in 0.469 second using v1.01-cache-2.11-cpan-49f99fa48dc )