Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question documentation - combination of stores memory/rest #202

Open
Jens-dojo opened this issue Mar 3, 2017 · 6 comments
Open

question documentation - combination of stores memory/rest #202

Jens-dojo opened this issue Mar 3, 2017 · 6 comments
Milestone

Comments

@Jens-dojo
Copy link

Jens-dojo commented Mar 3, 2017

Hello,

the documentation has really become very good. But I am struggling when it comes to combine stores.

I need

  • store for use in dgrid ondemandgrid
  • based on REST operations
  • all data should (also) be completely hold in memory, so that sort and filtering are done locally.
    Fetch and get/put/delete/post done by REST.

What would be the correct combination?

declare( [Rest, RequestMemory, Trackable])

Thank you for your help!!

@dylans
Copy link

dylans commented Mar 3, 2017

RequestMemory is really more of a one-time request and put into memory rather than a store with ongoing Rest operations. What you probably want is multiple stores, with a cache between them, similar to what was done in dojo/store. For example:

var restStore = declare( [Rest, Trackable] );
var cachedStore = Cache.create(restStore, {
    cachingStore: new Memory()
});

We should probably document this scenario better as its a common use case.

@dylans
Copy link

dylans commented Mar 3, 2017

fwiw, this is documented somewhat at https://github.com/SitePen/dstore/blob/master/docs/Stores.md#cache . Please let us know if you have suggestions on how we might make this more obvious @Jens-dojo .

@Jens-dojo
Copy link
Author

Dear Dylan,

thank you for the prompt reply!
If I use the Cache mixin with Rest store, then all the sort/filter operations trigger a new GET operation, something that seems problematic, as the data should already be in the Cache ?

@Jens-dojo
Copy link
Author

suggestions on how we might make this more obvious

Proposals for "Cache Store Mixin" docs

  • How does this internally work ? Is the original store changed, is it a second backup store ?
    Some words about the logic behind this mixin will help to undertstand and use it!

  • what stores (all ? only some?) can use the cache mixin ?

  • What do I have to do after initialising the store to get all data in it?

  • Cache stores and filtering /sorting and REST

  • Cache and Trackable (e.g. for dgrid): Something special I have to care about?
    Thank you!!

@dylans dylans added this to the 1.2 milestone Mar 31, 2017
@denov
Copy link

denov commented Nov 28, 2017

@Jens-dojo did you get this sorted out? i can get caching to work but not tracking using declare([ Rest, Cache, SimpleQuery, Trackable ])

@Jens-dojo
Copy link
Author

Hi,

I checked my source code (it is so long ago that I wrote it).

I have two combinations in my source code that I use. So these seem to work for me:
1)

define( [
		'dojo/_base/declare', 'dstore/Rest','dstore/Trackable','dstore/Cache'],
		function(declare,Rest,Trackable,Cache) {

	
	return declare([ Rest, Cache, Trackable ], {
		idProperty : 'uniqueid',
		
		postscript: function () {
			this.inherited(arguments);
			this.fetch();
		},
		
		isValidFetchCache: true
	});
	
	

} );

and
2)

define( [
		'dojo/_base/declare', 'dstore/RequestMemory',
		'dstore/Trackable'

], function(declare,RequestMemory,Trackable) {

	return declare( [
			RequestMemory, Trackable
	], {
		idProperty : 'uniqueid'
	} );

} );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants