Emberjs not able to find record that is in datastore (mongodb)

519 views Asked by At

After I update a record, then save the record; I refresh the page. Then I get this warning.

WARNING: Ember Data expected to find records with the following ids in the adapter response but they were missing: [5578caa125aa26c4770d0b49]

Form the ember inspector, all the attributes of the specific record are undefined except for the id. I know the record exists in the data store, because I looked it up in mongodb. Since the data is in the mongodb, but ember-data does not 'see' it, I can not use that record.

I googled the warning but all I got was references to the source code which I tried to figure out but was not successful.

Any help would be greatly appreciated.

Thanks.

Update 1

While I was trying to answer @jmurphyau question, I think I stumbled upon the issue but am not sure how to fix it. Basically, I have the following code.

var child = model.store.createRecord(...)
parent.save().then(function(parent){
  parent.get('children').pushObject(child);
  child.save().then( ... )
});

When I look at the JSON being returned. It seems as though the child is not being pushed onto the parent. But the child is being saved. Some how ember knows the parent is suppose to have that child, but the parent does not have the child, thus the warning. This make no sense to me but I am pretty sure I must be missing something.

Update 2

So I just deleted the parent and all the children. And then my code started working. And, I have not been able to reproduce the error. I do not know what was the problem. But thank you all for your input.

1

There are 1 answers

0
Andrey Mikhaylov - lolmaus On

When Ember saves the record, it sends a request to the backend. The server is expected to response either with an empty response or with a payload.

If the server responds with a payload, Ember accepts the payload in to the store.

Apparently, your backend responds with a payload that forces Ember to modify record(s) in the store. It might change/remove the ID of the saved record or its related records.

A more definitive answer can be given once you show the server's response as @jmurphyau requests. Please respond to this answer too so that I can update it.