Closed mike-wade closed 11 years ago
I posted answer :)
On Wed, May 8, 2013 at 9:15 PM, Michael Wade notifications@github.comwrote:
I posted http://stackoverflow.com/questions/16132102/compound-js-relationship-accessand have had a massive 71 views to date, with no solution, I also posted this in the mailing list but no one has been able to help so far. So hopefully someone here will be able to sort my code out [image: :smile:].
Here is the code I am having issue with (more detail on SO).
Schema:
var User = describe('User', function () { property('name', String); property('email', String); property('password', String); set('restPath', pathTo.users);}); var Message = describe('Message', function () { property('userId', String, { index : true }); property('content', String); property('timesent', Date, { default : Date }); property('channelid', String); set('restPath', pathTo.messages);}); Message.belongsTo(User, {as: 'author', foreignKey: 'userId'});User.hasMany(Message, {as: 'messages', foreignKey: 'userId'});
Action:
action(function show() { this.title = 'User show';
var that = this; this.user.messages.build({content:"bob"}).save(function(){ that.user.messages(function(err,message){ console.log('Messages:'); console.log(message); }); }); // ... snip ... }});
— Reply to this email directly or view it on GitHubhttps://github.com/1602/compound/issues/525 .
No joy with that solution yet :(
@anatoliychakkaev Any more suggestions? Updated the question on SO.
I posted http://stackoverflow.com/questions/16132102/compound-js-relationship-access and have had a massive 71 views to date, with no solution, I also posted this in the mailing list but no one has been able to help so far. So hopefully someone here will be able to sort my code out :smile:.
Here is the code I am having issue with (more detail on SO).
Schema:
Action: