Displaying posts – text, photo, and video
In the previous chapters, we implemented user management, including listing, showing, creating, updating, and deleting user entities. Now, we want to do the same with posts. To refresh your memory, we are planning to have User
posts. The posts can be either text, photos, or videos.
When we implemented the application skeleton, we created a Post
struct in src/models/post.rs
with the following content:
pub struct Post {
pub uuid: Uuid,
pub user_uuid: Uuid,
pub post_type: PostType,
pub content: String,
pub created_at: OurDateTime,
}
The plan is to use post_type
to differentiate a post based on its type and use the content
field to store the content of the post.
Now that we have rehashed what we wanted to do, let's implement showing the posts:
- The first thing we want to do is to...