kraih/mango — pull request #17 by SailingYYC (2014-05-05 09:14:22+00:00)
Title: Mango::BSON::_encode_object: TO_BSON

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:
```perl
$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.