● Update posts of people who have registered as favorites

Favorite registration button Get all user_id of the user and post_id posted by the user
Favorite list Display the timeline acquired by clicking the favorite registration button

I want to implement a function that allows you to search for a user from the search screen, and when you press the favorite registration button, you can get the user_id of that person with GET, register it as a favorite, and list the posts of those who have registered as a favorite. I was able to implement that function, but the posts newly posted by the person who registered the favorites cannot be updated in the list of favorites registered by myself. (Simply put, it's like everyone's posts on Twitter aren't updated)

Is it possible to achieve what I want to achieve with the current method in the first place? ??

Since I am a beginner, the information that I cannot understand without this information is ambiguous, so I will tell you if there is any information I want.

id name user_id
1 abc 1
2 acc 2
3 aaa 3

id name columnA
1 abc 1
2 acc 2
3 aaa 3

id user_id fish_id
1 abc 1
2 acc 2
3 aaa 3

  • Answer # 1

    Currently when you press the favorite registration buttonuser_idWhenpost_idIt is said that it is acquired and saved in the DB, but at this timeuser_idTry to save only.

    And at the timing of opening the favorite list,fishTableuser_idSearch with and get the latest listfishI think you can display.

  • Answer # 2

    I think it is necessary to rethink the database design in the first place.
    Regarding thisrelationI think that information etc. that you can expect will come out if you search with this keyword because it is deeply involved in.

    For example, in the favorite tableuser_idAs the name suggests in the columnuserofidI need to insert a different value (probably the username). From this relationshipuserofidShould be fine.

    Please design and examine the database in advance. If you neglect the design part here, it will be difficult to get what you can easily get and what you can insert.