
How do I approach showing likes count on a post ?
I have created a database which has the userID of the users who liked .
How do i show the number ?
I also wanna have a special “Top Liked” tag if the post has over 1,000 likes .
Is this done via functions or is there a way to do it via Databases ?

hey @Thatguyx! I believe to show the likes count, you can just query your likes
collection where you store the userIDs. Then, count how many userIDs are linked to that post. Like this:
const likedPost = await database.listDocuments('likesCollection', [
Query.equal('postId', postId)
]);
const likeCount = likedPost.documents.length;
and for the "Top Liked" tag, you can just check if the likeCount
is over 1,000, and if it is, you can set that tag:
let tag = '';
if (likeCount > 1000) {
tag = 'Top Liked';
}
umm, also, if you want to automate this (like updating the tag when it hits 1,000 likes), you could use an Appwrite function, but honestly, the database and a little logic in your app should do the trick. ^^
lmk if it works or if you need further help : )
Recommended threads
- Sharing Auth Provider Refresh Token
For some reason, the identities api always return empty "providerRefreshToken" property in response (in my case it is google), which make sense to not share wit...
- Change of billing cycle to support start...
Hii...is there any way to change my billing cycle from 20th to 1st...so that I aligns with my requirements.It becomes easier to track monthly usage crctly. I am...
- I am getting a 401 unauthorized response...
I have a Next.js application that stores user PDFs. I'm able to save them normally, but when trying to access the files using getFileView, I get a 401 Unauthori...
