Question

Is there a way to do dbrefs using the Perl API? Its not here nor is it anywhere here.

Here s a sample schema:

book: name, publisher,isdn,{author}
author : name,date of birth

I could just add a field to serve as the reference but wanted to do it with dbref instead.

Was it helpful?

Solution

There are no helpers for it, yet. DBRefs are just normal hashes, though, so you can access/create them yourself. They have the form:

 my $ref = {'$ref' => $collection_name, '$id' => $id};

See http://www.mongodb.org/display/DOCS/DB+Ref for more info.

OTHER TIPS

It's also handled by MongoDBx::Class, but this is a fully fledged ORM so it may not fit your use case.

https://metacpan.org/pod/MongoDBx::Class

Its handle by MongoDBx::AutoDeref.

https://metacpan.org/pod/MongoDBx::AutoDeref

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top