diff --git a/src/main/java/com/twitterclone/squeaker/repository/SqueakRepository.java b/src/main/java/com/twitterclone/squeaker/repository/SqueakRepository.java index 10f9b7c..fe48553 100644 --- a/src/main/java/com/twitterclone/squeaker/repository/SqueakRepository.java +++ b/src/main/java/com/twitterclone/squeaker/repository/SqueakRepository.java @@ -12,4 +12,5 @@ public interface SqueakRepository extends JpaRepository { List findAllBySqueakerOrderById(Squeaker squeaker); Squeak findSqueakById(Long id); + List findAllByOrderByIdDesc(); } diff --git a/src/main/java/com/twitterclone/squeaker/repository/entity/Squeaker.java b/src/main/java/com/twitterclone/squeaker/repository/entity/Squeaker.java index 84da1db..ce7ee9a 100644 --- a/src/main/java/com/twitterclone/squeaker/repository/entity/Squeaker.java +++ b/src/main/java/com/twitterclone/squeaker/repository/entity/Squeaker.java @@ -14,11 +14,19 @@ public class Squeaker { @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") Long id; - @Column(name = "username") + @Column(name = "username", unique = true) String username; @Column(name = "password") String password; @OneToMany(mappedBy = "squeaker") @JsonIgnore Set squeaks; + @Column(name = "first_name") + String firstName; + @Column(name = "last_name") + String lastName; + @Column(name = "profile_pic") + String profilePic; + @Column(name = "email", unique = true) + String email; } diff --git a/src/main/java/com/twitterclone/squeaker/service/SqueakService.java b/src/main/java/com/twitterclone/squeaker/service/SqueakService.java index cac1f30..f85de6c 100644 --- a/src/main/java/com/twitterclone/squeaker/service/SqueakService.java +++ b/src/main/java/com/twitterclone/squeaker/service/SqueakService.java @@ -21,7 +21,7 @@ public class SqueakService { public List findAllSqueaks() { - return squeakRepository.findAll(); + return squeakRepository.findAllByOrderByIdDesc(); } public Squeak findSqueakById(Long id) {