You can create all relationship in single `create` call too.
Example:
```js
constamidala=awaitUser.create({
username:'p4dm3',
points:1000,
profiles:[{
name:'Queen',
User_Profile:{
selfGranted:true
}
}]
},{
include:Profile
});
constresult=awaitUser.findOne({
where:{username:'p4dm3'},
include:Profile
});
console.log(result);
```
Output:
```json
{
"id":1,
"username":"p4dm3",
"points":1000,
"profiles":[
{
"id":1,
"name":"Queen",
"User_Profile":{
"selfGranted":true,
"userId":1,
"profileId":1
}
}
]
}
```
You probably noticed that the `User_Profiles` table does not have an `id` field. As mentioned above, it has a composite unique key instead. The name of this composite unique key is chosen automatically by Sequelize but can be customized with the `uniqueKey` option:
```js
...
...
@@ -617,4 +664,4 @@ Found game: "Winter Showdown"
So this is how we can achieve a *many-to-many-to-many* relationship between three models in Sequelize, by taking advantage of the Super Many-to-Many relationship technique!
This idea can be applied recursively for even more complex, *many-to-many-to-...-to-many* relationships (although at some point queries might become slow).
\ No newline at end of file
This idea can be applied recursively for even more complex, *many-to-many-to-...-to-many* relationships (although at some point queries might become slow).