You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a User Model with Many to many relationship with an Activity model.
The joint/merge table contains extra data. When I run the following code, only the user_id and the activity_id are inserted in the joint table.
user.activities = myActivities;
user.save();
Model looks like
User.hasMany(
'activities', // realtionship name on the model
Activity, // the related model
{
share: Number
}, // join table extra fields
{
mergeId: 'user_id', // Custom name for column referencing this model
mergeAssocId: 'activity_id', // Custom name for column referencing other model,
reverse: 'users' // define the same relationship in the other model as well with this name (getUsers() from the other side)
}
);
Any clue what's happening and how can I alter this? I prefer to have this so that I hit the database supposedly once for all of the myActivities elements instead of looping on each of the activities and using the setActivities function.
The text was updated successfully, but these errors were encountered:
I have a User Model with Many to many relationship with an Activity model.
The joint/merge table contains extra data. When I run the following code, only the
user_id
and theactivity_id
are inserted in the joint table.Model looks like
The
myActivities
looks likemyActivities = [{ 'activity_id' : 1, 'activity_name' : 'like', 'share' : 1 }];
Any clue what's happening and how can I alter this? I prefer to have this so that I hit the database supposedly once for all of the
myActivities
elements instead of looping on each of the activities and using thesetActivities
function.The text was updated successfully, but these errors were encountered: