Given an app, controller, model and repository (which holds representation of model), where should the sync service for the repository live?

In my specific implementation, my app/controller are AngularJS, models are generic JS and repository is a repository/datastore containing a representation of the data from model. The repository currently has some PouchDB code within it (set local and remote repo addresses; sync handler).

I'm assuming the sync code will be clearer/easier to work with if it exists in its own sync service or if I move it out of the repository and into the controller...

Should the repository class be responsible for syncing itself?

1 Answer 1


Depends what you mean by synching. Usually, a repository is used by controllers. So Controller is the one to draw from it and to place data back. Also, controller triggers methods like .save(), that in turn would be implemented by repository and will push data to persistence layer(PouchDB) in your case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.