Is there anyone that has had this problem before?
{"msec":14.00135300308466,"error":"Cannot read property 'relatedData' of undefined","data":{"isBoom":true,"isServer":true,"data":null,"output":{"statusCode":500,"payload":{"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"},"headers":{}}}}
The stacklogs points towards lib\eager.js but I think it's something with my models. My models are the following:
USER
var Bookshelf = require('../');
var UserIndividual = require('./UserIndividual');
var UserCharity = require('./UserCharity');
var User = Bookshelf.Model.extend({
tableName: 'user',
userDetails: function () {
// NAME TARGET TARGET
return this.morphTo('userDetails', UserCharity, UserIndividual);
}
});
module.exports = Bookshelf.model('User', User);
USERCHARITY
var Bookshelf = require('../');
var User = require('./User');
var UserCharity = Bookshelf.Model.extend({
tableName: 'user_charity',
user: function () {
this.morphOne('User', 'userDetails');
}
});
module.exports = Bookshelf.model('UserCharity', UserCharity);
Your relation functions need to return a value.
On Sat, 5 Dec 2015 at 09:42 xavier geerinck [email protected]
wrote:
Is there anyone that has had this problem before?
{"msec":14.00135300308466,"error":"Cannot read property 'relatedData' of undefined","data":{"isBoom":true,"isServer":true,"data":null,"output":{"statusCode":500,"payload":{"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"},"headers":{}}}}The stacklogs points towards lib\eager.js but I think it's something with
my models. My models are the following:USER
var Bookshelf = require('../');var UserIndividual = require('./UserIndividual');var UserCharity = require('./UserCharity');
var User = Bookshelf.Model.extend({
tableName: 'user',
userDetails: function () {
// NAME TARGET TARGET
return this.morphTo('userDetails', UserCharity, UserIndividual);
}
});
module.exports = Bookshelf.model('User', User);USERCHARITY
var Bookshelf = require('../');var User = require('./User');
var UserCharity = Bookshelf.Model.extend({
tableName: 'user_charity',
user: function () {
this.morphOne('User', 'userDetails');
}
});
module.exports = Bookshelf.model('UserCharity', UserCharity);—
Reply to this email directly or view it on GitHub
https://github.com/tgriesser/bookshelf/issues/1054.
I can not believe I just looked over that return all the time ... Thanks! You literally saved my day haha!
This just totally saved me, can't believe I missed that as well.
Most helpful comment
Your relation functions need to return a value.
On Sat, 5 Dec 2015 at 09:42 xavier geerinck [email protected]
wrote: