A
A
Abc Edc2016-11-01 15:53:53
MongoDB
Abc Edc, 2016-11-01 15:53:53

How to create a user immediately with a role without overriding default methods in Loopback?

I inherited the model

{
  "name": "user",
  "plural": "users",
  "base": "User",
  "relations": {
    "roles": {
      "type": "hasMany",
      "model": "Role",
      "foreignKey": "principalId",
      "through": "RoleMapping"
    }
  }
}

Can I immediately associate it with the role without redefining custom remote methods?
Well, that is, in order not to write something like
create a user -> take a user instance -> bind a role
Because I know that in the loopback out of the box there are a lot of interesting things like includes, etc., so for sure it automatically makes such transactions
what the body should be request?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question