jakubrohleder / angular-jsonapi

Simple and lightweight, yet powerful ORM for your frontend that seamlessly integrates with your JsonAPI server.
http://jakubrohleder.github.io/angular-jsonapi/
GNU General Public License v3.0
95 stars 34 forks source link

How to easily remove local store option #19

Closed desouzamaria closed 8 years ago

desouzamaria commented 8 years ago

We are having some problems with the local storage cache mainly the size causing erratic behavior.

Can we easily set it not to use local store for our development phase.. I used this. But resource comes undefined. //factory var restSynchro = $jsonapi.sourceRest.create('Rest source', restUrl); var synchronizer = $jsonapi.synchronizerSimple.create([ restSynchro]);

//controller var resource = $jsonapi.getResource('test');

If I use the local store it works: //factory var localeSynchro = $jsonapi.sourceLocal.create('LocalStore synchronization', 'app'); var restSynchro = $jsonapi.sourceRest.create('Rest source', restUrl); var synchronizer = $jsonapi.synchronizerSimple.create([localeSynchro, restSynchro]);

jakubrohleder commented 8 years ago

By 'resource comes undefined.' you mean $jsonapi.getResource('test') === undefined?

desouzamaria commented 8 years ago

Yes.

Also, I have a simple app to test the API where I get the results using $http. And this works: $http.get(restUrl,{query: { method:'GET', isArray: false }}).success(function(res) { $scope.test = res.data; });

jakubrohleder commented 8 years ago

@desouzamaria that's 99% your fault :). Have u called $jsonapi.addResource(schema, synchronizer);? and is the schema.type same as the resource name u are trying to get with $jsonapi.getResource? (in your example test)

I also recommend you checking demo directory, especially code in demo/resources/*.

If you are 100% sure everything is ok, please provide me with some more specific example, so I can recreate the issue.

desouzamaria commented 8 years ago

@jakubrohleder I certainly do have this line, after I create the synchronizer: $jsonapi.addResource(schema, synchronizer);

Also, I made sure the schema.type is same as the resource name. As I said before It works when I have the local store defined and passed to synchronizerSimple.create.

I have got down your demo example and checked it.

Perhaps you can give an example of a factory and controller that does not use the local store.
Thanks

jakubrohleder commented 8 years ago

@desouzamaria Sorry for the long time waiting, I did not manage to prepare demo for you earlier. Have you solved this issue already? If not I'll prepare a no-local-store demo for you.

jakubrohleder commented 8 years ago

@desouzamaria Sorry for the long time waiting, I did not manage to prepare demo for you earlier. Have you solved this issue already?

If not I'll prepare a no-local-store demo for you.

desouzamaria commented 8 years ago

Thanks. We are currently using another way of integrating with the API.

mabdurrehman commented 8 years ago

@desouzamaria Can you please let me know What is other way of integrating with the API.