I have hasMany relationship on my Profile object, when Profile.find returns and automatically injects the Profile it also injects the hasMany relationship for Suggestions. Unfortunately it doesn't call beforeInject as it used to before I switched over to js-data. When I step through the js-data code I noticed something odd. definition.beforeInject is defined correctly, but right after DSUtils._ is called, options.beforeInject is set to default method rather than my override.
var name = definition.name;
options = DSUtils._(definition, options);
if (options.notify) {
options.beforeInject(options, attrs);
var definition = {
name: 'profile',
defaultAdapter: 'profileAdapter',
relations: {
hasOne: {
user: {
localField: 'owner',
foreignKey: 'id'
}
},
hasMany: {
suggestion: {
localField: 'suggestions',
foreignKey: 'ownerId'
}
}
},
computed: {
id: ['owner', _updateId]
},
methods: {
// Instance methods
updateLinks: _updateLinks
}
}
var definition = {
name: 'suggestion',
defaultAdapter: 'suggestionAdapter',
relations: {
belongsTo: {
user: {
localField: 'owner',
localKey: 'ownerId'
}
}
},
computed: {
ownerId: ['owner', _updateOwnerId],
votes: ['totalVotes', ParseData.defaultValueHandler(0)],
skips: ['skipped', ParseData.defaultValueHandler(0)],
views: ['votes', 'skips', _updateViews],
slug: ['text', _updateSlug],
link: ['slug', 'id', _updateLink],
kdr: ['votes', 'skips', _updateKdr],
typeClass: ['type', _updateTypeClass],
typeDisplay: ['type', _updateTypeDisplay],
url: ['url', _updateUrl],
imageUrl: ['type', _updateImageUrl]
},
methods: {
// Instance methods
updateLinks: _updateLinks
},
beforeInject: _beforeInject,
afterInject: _afterInject
}
I'll see if I can put together a plnkr to illustrate this.