dimanche 17 septembre 2017

Ember 2, Maybe I did not understand the use and purpose of ember-pouch. Perhaps not useful for what I have to do?

I have a simply application with ember-data that uses DS.JSONAPIAdapter in adapters/application.js because I'm using a backend with JSON API.

import DS from "ember-data";
import DataAdapterMixin from "ember-simple-auth/mixins/data-adapter-mixin";
import ENV from "../config/environment";

export default DS.JSONAPIAdapter.extend(DataAdapterMixin, {
  host: `${ENV.API_HOST}`,

  namespace: "api"
});

Now I need for some models (and in some scenarios) the user can use my application also in offline mode.

So I thought at pouchdb and ember-pouch. But maybe I was wrong.

Let's say I today write a new post and click the save() button. Now my post is saved through ember-data which is online and says to my server backend to save it through application adapter.

Now my server can save or not this post (maybe it can refuse it because of many words or maybe other validations server-side only).

So after save() my server can say NO! to my client (and to ember-data) or maybe YES!: so I have logical, business operations in my server backend.

With ember-pouch I don't understand:

  • I really need ember-pouch for this problem?
  • how to backup data in client (when offline) just for some models (let's say post and category and tags);
  • how to add ember-pouch just to handle offline mode and retry operations when online for that models using my server backend (and also a couchdb one just for ember-pouch);
  • maybe I'm wrong because any application that uses ember-pouch has to do without the server using only couchdb one? So all the logic is just in client (ember) side? Is this one the right way?
  • how to add ember-pouch in an application just for some models using belongsTo relationship with standard ember-data models?



Aucun commentaire:

Enregistrer un commentaire