ember.js - Returning record(s) after store pushPayload call -


What is a better way to bring back records after DS.Store # pushPayload ? This is what I am doing ...

  var payload = {id: 1, title: "example"} store.pushPayload ('post', payload); Return store.getById ('Post', Payload.Id);   

But, regular DS With the store # push you get the record back entered, the only difference between the two, which I can tell, is that D. Store # Pushpeload serializes the payload data with the correct serializer.

DS.Store # pushPayload an array of objects is not the only one, and it may contain side-loaded data, it does a complete payload process and requires the route in the payload:

  {"posts" : [["Id": 1, "title": "title", "comments": [1]}], "comments": [// .. and so on ...]}   

ds Store # Push Expecting a single record is normalized and does not have any side loaded data (note no root key):

  {"id": 1, "title": "title", "comments": [1]}   

For this reason, it makes sense for push for the record , But not to return anything for pushPayload .

When you use pushPayload , then store.find ('post', 1) (or store.getById (' post ', second look of 1)) ) is the way to go, I do not believe there is an better method.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -