How to strapi auto add field relationship

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!

You can do that through lifecycles, I think you can find different tutorials about it.

We used it to create profiles automatically after user’s registering.

Actually, I can set user id to table Post in order to get results like this. But I wanna it automatically without adding any line of code.
Can you for me a littel tutotials, i cant find out them.Thank you!

What’s your use case?

Why must it be without any code line? Most of this stuff needs to code.

I have some troubles with relationships too.
Although I added some relationships to some models, the connected models do not appear in the results of the queries…
I suppose that Trang is facing a similar issue…

Which kind of relations are you using? Did you review them on the documentation?