Kapelianovych / couchdb_dart

A library for Dart developers for work with CouchDB

Home Page:https://pub.dev/packages/couchdb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API improvements?

dominickj-tdi opened this issue · comments

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.

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

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.

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.

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.