M
M
maxemga2021-06-11 09:33:12
Express.js
maxemga, 2021-06-11 09:33:12

How to make Tweet logic in React and Express?

I am writing a social network for practice, like a tweeter and a question, I want to add the ability to tweet (so that you can tweet on your page and on others). And for this it is necessary that in the database the tweet is assigned to the person who made the tweet so that the name and photo are displayed, but what is the best thing to do, make an array of tweets in the Document with the User and write all the tweets or a separate collection there and put all the tweets there, but bind to a person by id/name? I just don't know exactly how it does and I want to clarify

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2021-06-11
@maxemga

Well, look, you create a table with posts, work with id.
id = int - auto_increment
Next output to the posts page while making a shared page to avoid the puzzle (trust me)
Add a "repost" button is ok.
Create a route on the express /repost, for example, with the POST type
B1 - Add a table of users where one of the fields will be reposts
B2 - create a table for reposts where specify the user id + post id
If B1 - pull data from this column, push new id there and write down
If B2 - the same, only for fields with id - user and parent_id - post id.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question