Trying to stitch-in a complete working restful store with PHP backend
from various web posts. So I apologize for sending different questions
around
the same topic.
But my results do not work the same way that I think, the examples were
intending
for example. This is how I define the service and store.
--------------------------------------------------
var crmService = function(query, queryOptions) {
console.log('calling query: ',query, " with options: ",queryOptions);
return dojo.xhrGet({url:"services",
handleAs:'json',content:{action:'query',"query":query,
"queryOptions":queryOptions}});
};
crmService.post = function(id, value) {
console.log('calling add with id:',id, ' and value: ',value);
return dojo.xhrPost({url:"addService", handleAs:'json',
content:{action:'add',"id":id, "value":value}});
};
var crmServicesStore =
new dojox.data.JsonRestStore
({target:"<?php echo $controller; ?>",
service:crmService,
syncMode:false
});
----------------------------------------
for some reason the arguments passed in to the functions above are
a) different between Restore and PersevereStore
b) ID argument to the add is never populated (empty string)
(I am checking it by printing out $_REQUEST array in php
To point a)
the initial query shows as
Object
name:'*'
console.log('calling query: ',query, " with options: ",queryOptions);
and does NOT get serialized to a string xhrGet
(however the example here
http://blog.medryx.org/tag/jsonreststroe/ )
does not have any special login to serialize the 'query' object
On the other hand, when using PerserveStore, the query is already a
serialized string (of course with different syntax than the RestStore
query)
so that one shows up up $_REQUEST array in PHP
and where does RestStore get the property name 'name' for the query, is
this
a default?
The 'id' value never gets populated on the store.newItem (that invokes
crmService.post )
Unlike typical stores, I guess, I do not need to define the 'identity'
element
or the store schema at all, I see that __id element in the item gets
always
populated with some random but unique number. Which is good for me.
So wanted to ask for recommendation
my basic need is a Store that
a) sends update/delete/updates to my PHP server
b) does not go to the server if the query finds at least one item in
internal memory
(or if I specify some argument like cache:true or something similar)
c) tells me the identity of the item being sent
d) does not require me to manage the identity items
I think the stores above do all (or most) of the things above, but may
be I just
cannot find the right combination of switches in the plethora of options
and documents
available....
Vlad
--
Vlad P
author of C++ ORM
http://github.com/vladp/CppOrm/tree/master--
http://www.fastmail.fm - Access your email from home and the web
_______________________________________________
FAQ:
http://dojotoolkit.org/support/faqBook:
http://dojotoolkit.org/docs/bookForums:
http://dojotoolkit.org/forumDojo-interest@...
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest