How to represent a list of entities within a table of the same entity in PostgreSQL? I have a table called user with an attribute friendsList which has to be a list of ids pointing to different users. I really have no clue how to do this using Postgres
There's a couple of ways you can go about this but the most relational and normalized way would be to create a second table called UserFriendList with the columns UserId and FriendUserId which would store one row per Friend for each User. This table would be one-to-many from User.Id to UserFriendList.UserId but would also be able to help bridge the join back to the User table on UserFriendList.FriendUserId to User.Id to get all the User attributes of the friends. This kind of table is known as a bridge / junction / linking table.
Example query with this design:
SELECT 
    User.Id AS UserId, User.FirstName AS UserFirstName, User.LastName AS UserLastName, 
    Friend.Id AS FriendUserId, Friend.FirstName AS FriendFirstName, Friend.LastName AS FriendLastName
FROM User
INNER JOIN UserFriendList
    ON User.Id = UserFriendList.UserId
INNER JOIN User AS Friend
    ON UserFriendList.FriendUserId = Friend.Id

Alternatively you can store the FriendList column directly on the User table as either a comma delimited list or in JSON, but these are both denormalized solutions, which will become harder to maintain changes, potentially lead to data redundancy, and will inflate the size of your User table which could make querying it less efficient.