-
Notifications
You must be signed in to change notification settings - Fork 8
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
Deleting document #9
Comments
@seifsallam can you post a gist or stypi.com page of the models' code; also what versions of Ember, Ember Data are you using? Are you using a version of ember-data-extensions that matches your ember data version? Also include your ApplicationAdapter and ApplicationSerializer code in the shared code snippet. Also, it would be helpful to see the JSON payload for your GET then DELETE responses, I don't then the server sends any payload on DELETE though. |
I'm using PostSerializer = ApplicationSerializer.extend(
DS.EmbeddedMixin
attrs:
place:
embedded: 'always'
)
App.Post = DS.Model.extend(
place: DS.belongsTo 'place'
)
Place = DS.Model.extend(
country: DS.attr()
state: DS.attr()
city: DS.attr()
) |
Place should also belongTo Post, see: http://emberjs.com/guides/models/defining-models/#toc_defining-relationships |
But i don't pass the post id in the place |
@seifsallam See the example payloads in the docs here: http://pixelhandler.github.io/ember-data-extensions/docs/classes/DS.EmbeddedMixin.html The embedded records have foreign keys. The mixin doesn't support ID-less records, as Ember Data doesn't support that either. A raw object could be used instead, but then you wouldn't need a place model or the relationship defined in post; and then no need for the mixin either. |
Ok. will give it a shot and get back to you |
Still the same problem :( Place = DS.Model.extend(
country: DS.attr()
state: DS.attr()
city: DS.attr()
post: DS.belongsTo 'post'
) |
@seifsallam this test file has a bunch of examples how the mixin works: https://github.com/pixelhandler/ember-data-extensions/blob/master/packages/mixins/tests/embedded_mixin_test.js Perhaps make a jsbin, something like http://emberjs.jsbin.com/iCIXuzI/6/edit?html,js,output that mocks the server responses. |
@seifsallam perhaps put a breakpoint at line 261 here : https://github.com/pixelhandler/ember-data-extensions/blob/master/packages/mixins/lib/embedded_mixin.js#L257-L264 and inspect the partial variable. |
Ok, will investigate further and get back to you |
The partial is set as undefined. |
That's is were it's breaking, so from there you can debug why; or create a jsbin for others to help debug. My guess is that the payload is missing something, the start of the back trace is in |
Is the data supposed to be like that? with recordId value and empty payload?
|
Can you make a jsbin example of your issue? (Then I could inspect it) |
Ok, will try to do that |
@pixelhandler Sorry for the long delay. I've tried to make it work in a jsbin but there are two problems. First i can't get it to work with ember-data-ext. Second i don't know how to make |
@pixelhandler Any recommended ways for creating and deleting records. As of now i gave up using embedded for Lets say i have Also for inserting embedded, I get duplicate values after each |
@seifsallam the EmbeddedMixin in this library does not extend any create / delete behaviors that Ember Data already provides only serialization for embedded. The only way I could help debugging the issue you brought up would be to see the code running for example in a jsbin or jsfiddle example. Or if you wrote a failing unit test for the issue. At work I use these extensions for ember data and do have success saving and deleting. Also I find that I need to write patches for open bugs in Ember Data, as it is still beta. I would suggest trying w/o embedded records and see how it goes. As for duplicates after saving a record with a hasMany relationship there have been bugs reported on that topic in Ember Data. |
@pixelhandler I've made a version here http://emberjs.jsbin.com/konos/2/edit, i still don't know how to make jsbin work with ember-data-ext |
@pixelhandler Any luck here? |
@seifsallam Here is a working jsbin http://jsbin.com/nedel/3/edit?html,js,output and the gist: https://gist.github.com/pixelhandler/9480904 |
@pixelhandler Thanks a lot for your help. In your jsbin you were using status 204 when delete succeeds. This fixed the issue of looking for embedded data. It would be awesome if this is mentioned in the wiki. Again thanks :) |
I have a document with embedded as
belongs_to
, when i delete the parent document i receive.The text was updated successfully, but these errors were encountered: