Embedded records without IDs


#1

Hello!

I must retrieve data from a web API that serves JSON. I do not have control over it and the served JSON is not compliant with ember store format (please see hereunder). Is there any way to get Ember Data to store records without ID ? Or how could I get it to automatically add ID’s to records upon retrieval ? I would need IDs on “charts” and “points” items since I have a “chart” Model and a “point” Model in my Ember app.

Here is a short example of the data I receive from the WS

"charts": [
	{
		"key": "group1",
		"points": [
			{
				"xValue": 1,
				"yValue": 21
			},
			{
				"xValue": 20,
				"yValue": 150
			}
		]
	},
	{
		"key": "group2",
		"points": [
			{
				"xValue": 1,
				"yValue": 54
			},
			{
				"xValue": 20,
				"yValue": 126
			}
		]
	}
]

#2

ember data doesn’t support id-less records.

since this looks like read-only data, i would recommend not using ember data for that model and instead fetch the data with normal ajax requests.

if you really need to use Ember data: you can, and i have done this, use the guidFor method within the ember namespace to assign ids, but this would only allow you to push records into the store, and then retreive them, which seems kind of pointless if you don’t need to perform CRUD on the data


#3

I don’t know how can I use “guidFor”, could you show me an example, Please.