If you’re creating a custom adapter you can take the JSON returned from the server and massage it into something that works better with ember data.
EDIT: I’m not sure if your adapter is a extension of the RestAdapter or not but this should give you an idea of what the payload returned from your server should be massaged into: http://emberjs.com/guides/models/the-rest-adapter/
Thanks @hooper, for taking the time to help! I am indeed extending RestAdapter.
The code I am using client side in my SocketAdapter is this (the makeSocketRequest was borrowed from @jthoburn). It works great for the find() and findAll() functions I have implemented. However I am struggling with findQuery().
findQuery: function (store, type, query) {
var url = '/'+type.typeKey+'/find';
return this.makeSocketRequest(store, url, {
query : query
});
},
makeSocketRequest : function (store, eventType, query) {
var self = this;
return new Ember.RSVP.Promise(function (resolve, reject) {
try {
self.socket.emit(eventType, query, function (data) {
if (data.status) {
data.content = JSON.parse(data.content);
resolve(data.content);
} else {
reject(data);
}
});
} catch (e) {
reject({ message : 'App.Socket is not available for requests'+e});
}
});
},
Error while processing route: room.index Assertion Failed: The response from a findQuery must be an Array, not {room: [object Object]} Error: Assertion Failed: The response from a findQuery must be an Array, not {room: [object Object]}
It obviously wants an array, but this is where I am stuck. I don’t know if the JSON should be formatted in another way (not clear from the link you sent) or if I should be doing something else in the adapter with the resulting JSON returned from the server.
findQuery assumes that the server will return possibly more than one result. If your response was {"rooms": [{"id":1,"url":"xx","name":"Lobby","messages":[]}]} then things would probably work. Does your endpoint only return one record?
Error while processing route: room.index Assertion Failed: The response from a findQuery must be an Array, not {rooms: [object Object]} Error: Assertion Failed: The response from a findQuery must be an Array, not {rooms: [object Object]}