simple-orm / core

A simple ORM for NodeJS
MIT License
2 stars 0 forks source link

Combine toJSON and toJsonWithRelationships #26

Open ryanzec opened 10 years ago

ryanzec commented 10 years ago

There is no real reason we should not be able to combine toJSON() and toJSONWithRelationships() to one configurable method call.

ryanzec commented 10 years ago

Thinking about this more, since toJSONWithRelationships() returns a promise (since the relationship might not be loaded as the time of calling) we really can't combine them. From what I am seeing, toJSON() should be returning a regular value and toJSONWithRelationships() needs to return a promise.

Eager loading is something that needs to be looked at and if it is implemented, toJSON() should should probably include any relationships that have been loaded (with options to manage this). Will keep this open until eager loading is looked at.