DavidDuwaer / Coloquent

Javascript/Typescript library mapping objects and their interrelations to JSON API, with a clean, fluent ActiveRecord-like (e.g. similar to Laravel's Eloquent) syntax for creating, retrieving, updating and deleting model objects.
MIT License
193 stars 25 forks source link

Allow overriding methods or properties #66

Open paul-thebaud opened 4 years ago

paul-thebaud commented 4 years ago

Hi!

It would be great to have the possibility to override more methods of the tool, essentially in Model. This will require changing their visibility from private to protected.

For example, I would like to override the get method for Models and builders where I don't have pagination, but the query of the builder is a private attribute.

filipedtristao commented 4 years ago

@DavidDuwaer It's a very good idea, i think the methods and props should be all protected to allow overrinding.

Can i do a PR for this?

DavidDuwaer commented 4 years ago

I think this is an easy way to allow use for many more edge cases. Most importantly I think it spurs organic growth of good inventions/additions that can later be added into the library itself.

That said, these methods being overridable should not expand the API's "surface" that is required to maintain backward compatibility going onward. In other words, overriding the internals of the API by users of the library should be done at own risk. So we should state that clearly in those methods' docs. Then it's fine by me!

paul-thebaud commented 4 years ago

@DavidDuwaer I understand. In every case, methods which are public or protected should be more documented to understand the impacts of changing their behavior. I leave this issue open since @filipedtristao proposed a PR.