View Full Version : how to attach arbitrary fields of a model when you sync a store?

6 Apr 2013, 11:50 AM

first of all i know how to send an parameter attached to a request (params config), but here is my problem :

assume that you have a store of a specific model containing for e.g. 11 fields .
and the store have four different Urls for Create, Update, Read and Destroy.
when you are destroy a record , you want to send exactly 5 fields of the model, and in a similar way
for 3 other action you may want all fields or just some of them .

how you can tell the store that which fields should be attached to request on every actions?

I've found the writeAllFields config for proxy , it's not bad , when you make a field.persist = false , that field doesn't attach to request , But i feel that a a little bit dirty . i think the is a beautiful trick for this , and i really need to know that.


8 Apr 2013, 12:12 PM
I suspect using persist: false per field per condition is about as elegant as it gets. Sounds like you're wanting to declaratively say what fields you want sent on a given API action from the writer - perhaps do your own extended writer class with those conditions/actions defined.

8 Apr 2013, 11:59 PM
yes, you are right and that's why i'm looking for a better solution.
i have considered writer as well . honestly i don't like it either.

i was thinking about a property on model fields , so you can take the model from the beginning that it can attached that specific field by default or not.