Closed jrcastillo closed 8 years ago
So I kept on trying unconventional solutions to see how this error behaved, and it turns out that when parsing, it is looking for model.attributes.id
instead of model.id
. So I tried changing in my DB category table changed slug
-> id
, and my bookshelf model to:
var Activity = bookshelf.Model.extend({
tableName: 'activities',
hasTimestamps: true,
// Relationships
tags : function(){
return this.belongsToMany('Tag','has_tags','activity_id','slug')
}
});
var Tag = bookshelf.Model.extend({
tableName: 'tags',
idAttribute: 'id', // change from slug to id
timestamps: true,
activities: function() {
return this.belongsToMany('Activity');
}
});
This work around works perfectly, but is not the best for me. Anything to be done over this issue would be awsome.
@jrcastillo looks like this was just resolved. Please try again and let us know if you have any additional issues.
@jamesdixon thanks, I also work for the zoi travel team and helped @chamini2 to develop the solution. It works perfectly, no errors for now
Ah, thanks @jrcastillo -- appreciate your contributions!
Hey, I'm currently using this mapper to parse some models and has worked for the charm until I encountered this error that for to-many relationships. Here is my object model sent to the mapper. The error is that the mapper is passing undefined ids to the relationships and the inclusions
here is the output of the mapper
To be more specific here are the model definitions used
Any help with this matter would be greatly appreciated. Thxs