Skip to content
This repository has been archived by the owner on Dec 11, 2017. It is now read-only.

Mango::BSON::_encode_object: TO_BSON #17

Closed
wants to merge 1 commit into from
Closed

Mango::BSON::_encode_object: TO_BSON #17

wants to merge 1 commit into from

Conversation

SailingYYC
Copy link

Permit object encoding to preferentially request a different representation for storage vs JSON from blessed objects.

Due to the schema-less nature of MongoDB, all "schema" is stored on a record by record basis. There is a fair deal of overhead in large implementations and it is best practice to use short field names.

Ie. All data is stored in MongoDB and in the blessed object using 2-3 character field names, but for readability all output representations (XML, JSON, or object accessors) use long human readable variations.

Eg:

$obj->account('@user')->email('user@example.com');
$obj->TO_JSON;
# { account => '@user', email => 'user@example.com' }

$obj->TO_BSON;
# { ac => '@user', e => 'user@example.com' }

I had worked with Mike Friedman to have this same functionality added to MongoDB's perl driver with the inclusion of a non-recursive encoding algorithm, although I've not been able to find the status of said request.

Permit object encoding to preferentially request a different representation for storage vs JSON from blessed objects.
@kraih
Copy link
Owner

kraih commented May 5, 2014

👍 for the functionality from me, but i can't apply the patch until there are tests.

@kraih kraih closed this in 511687c May 5, 2014
@kraih
Copy link
Owner

kraih commented May 5, 2014

I've added the feature now, in the future please be aware that Mango follows the same rules as Mojolicious, so every new feature needs a test and documentation.

@SailingYYC SailingYYC deleted the patch-1 branch May 5, 2014 23:23
@SailingYYC
Copy link
Author

@kraih, I do apologize. I should have posted as an issue and sought your feedback then made the full pull request. Unfortunately I called it a night and didn't get back to publish the full PR until after you completed the request.

Again, thank you, Mango solves so many of the issues and workarounds I had to make for the "official" Mongo driver.

@kraih
Copy link
Owner

kraih commented May 6, 2014

Our preferred ways for discussing work in progress features are IRC and the mailing-list, pull requests are mostly just for yes/no votes. http://mojolicio.us/perldoc/Mojolicious/Guides/Contributing#CONTRIBUTING_CODE

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants