feathersjs sequalize Belongs-To-Many associations Invalid value

440 Views Asked by At

I am upgrading an Express application to Feathersjs application. I have the following model definition for belongs_to_many associations:

Clase A (usergroup):

  userGroup.associate = function (models) { 
    models.user_group.belongsToMany(models.permission, {through: 'user_group_permission'});
  };

Class B (permission):

  permission.associate = function (models) { 
    models.permission.belongsToMany(models.user_group, {through: 'user_group_permission'});
  };

With that definition, we sould be able to create a group and use the addPermission/addPermissions method to associate permissions to a group.

The following code intends to associate permissions with a group

      newGroup = await Model.create({
        groupName: data.groupName
      });
      newGroup.addPermissions(plist);

where Model is the variable for the UserGroup model class, and plist is a list of Permisssions.

This code is written in a service class generated by the feathers generate service command. Following this suggest, I overwrote the create method. The goal is to work with the permission list provided in create group endpoint.

The result is this one:

Rejection

In the following image we can see the cause of the exception The stacktrace

What is wrong with models definition if with Express application the same code works fine?

0

There are 0 best solutions below