Kapelianovych / couchdb_dart

A library for Dart developers for work with CouchDB
https://pub.dev/packages/couchdb
Other
47 stars 18 forks source link

API improvements? #9

Closed dominickj-tdi closed 5 years ago

dominickj-tdi commented 5 years ago

These would be breaking changes, but I thought I might run them by you to see what you think.

Rather than having to call .documentModelResponse() and the like on the DBResponse object I receive, it would make more sense to me if the various functions and methods just returned the correct type of response directly. We could do away with DBResponse, and just make it an abstract interface, perhaps with a factory constructor that would create the correct response type when called.

dominickj-tdi commented 5 years ago

I should note I would be willing to help implement these changes if you decide the ideas have merit.

Kapelianovych commented 5 years ago

Hello. It will be many instances that describe responses from database. This will be awkward. Early before documentModelResponse was only DbResponse class that contains all possible fields. Hard to maintain feature. Instead of convertation to documentModelResponse directly, I propose doing it inside of methods in each model class, so you will get converted response, not DbResponse.

dominickj-tdi commented 5 years ago

Having the model classes handle conversion makes sense to me. It would probably be pretty easy to implement that way, but still have the same advantage making the API a little clearer and easier to use.

Kapelianovych commented 5 years ago

Ok. I will take a look for your pull request. I agreed that current DbResponse isn’t the best, so a new way to represent response is required.