Created
November 27, 2013 23:03
-
-
Save thomasqbrady/7684611 to your computer and use it in GitHub Desktop.
Trying to understand how to introspect hasMany related models in Ember/Ember Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doc = DS.Model.extend({ | |
// relationships | |
metadata: DS.hasMany('metadatum',{ async: true }), | |
................... | |
var Metadatum = DS.Model.extend({ | |
// relationships | |
doc: DS.belongsTo('doc'), | |
................... | |
Then in a contoller whose content is an Ember Data Store full of docs: | |
this.get('content').forEach(function(doc){ | |
console.log(doc.get('metadata'));// NULL | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Json for docs:
{
"docs": [
{
"__v": 1,
"_id": "5295802d8789d43f7a00000c",
"createdAt": "2013-11-27T05:16:29.098Z",
"file_name": "01042010_bdo",
"fiscal_year": "2010",
"id": "5295802d8789d43f7a00000c",
"img": "",
"metadata": [
"5295802d8789d43f7a00037d",
"5295802d8789d43f7a000392",
"5295802d8789d43f7a000361",
"5295802d8789d43f7a00038b",
"5295802d8789d43f7a00036a",
"5295802d8789d43f7a000386",
"5295802d8789d43f7a000384",
"5295802d8789d43f7a000378",
"5295802d8789d43f7a000360"
],
"name": "OOO January 04, 2010",
"pub_date": "2010-01-04T06:00:00.000Z",
"short_desc": "In Consectetuer Ipsum Nunc Id Enim. Curabitur Massa. Vestibulum Accumsan Neque Et Nunc. Quisque Ornare Tortor At Risus.",
"type": "ooo"
}
],
"metadata": [
{
"__v": 0,
"_id": "5295802d8789d43f7a00035b",
"id": "5295802d8789d43f7a00035b",
"type": "author",
"value": "Thomas Brady"
}
]
}