0
{
"name": "user",
"plural": "users",
"base": "User",
"relations": {
"roles": {
"type": "hasMany",
"model": "Role",
"foreignKey": "principalId",
"through": "RoleMapping"
}
},
を継承したとフックを作成し、successfulyデシベル(モンゴ)に追加したユーザー
UserModel.afterRemote('create', (context, user, next) => {
let body = context.req.body;
if (!body.hasOwnProperty('roleId')) {
next();
}
Role.findById(body.roleId)
.then(role => {
if (!role){
next();
}
return user.roles.add(role);
})
.then(roleMapping => {
next();
});
});
とレコードとの役割を保存するための、しかし要求が
/api/users?access_token={}[include]=roles
レコードを取得しながら、参加していない、なぜですか?