I have two collection types is Post and User. And relationship is Post has one User.
I create a new post by api: http://localhost:1337/posts through auth token of a user and result like this:
{
"id": 7,
"content": "Noi dung bai viet",
"slug": "tieu-de-bai-viet",
"title": "tieu de bai viet",
"published_at": "2021-06-08T15:45:00.186Z",
"created_at": "2021-06-08T15:45:00.197Z",
"updated_at": "2021-06-08T15:45:00.197Z",
"type_of": "article",
"description": "Mo ta noi dung",
"path": null,
"url": null,
"reactions_count": null,
"tags": [],
"user": null,
"cover_image": null
}
But i want it auto add user into database like below:
{
"id": 7,
"content": "Noi dung bai viet",
"slug": "tieu-de-bai-viet",
"title": "tieu de bai viet",
"published_at": "2021-06-08T15:45:00.186Z",
"created_at": "2021-06-08T15:45:00.197Z",
"updated_at": "2021-06-08T15:45:00.197Z",
"type_of": "article",
"description": "Mo ta noi dung",
"path": null,
"url": null,
"reactions_count": null,
"tags": [],
"user": {id:1,name:"cheng",email:"email@gmail.com"},
"cover_image": null
}
So how can config to strapi do that, or if cant, how i must handel in controller?
Thank you!