follow users

This commit is contained in:
2025-08-29 14:11:55 +02:00
parent 0699ac9ea8
commit 5473beb988
6 changed files with 229 additions and 55 deletions
+20
View File
@@ -0,0 +1,20 @@
import { followsRef } from "../config/firebase";
export const getFollowersCount = async (userId) => {
if (!userId) return 0;
const snap = await followsRef.where("followeeId", "==", userId).get();
return snap?.size || 0;
};
export const getFollowingCount = async (userId) => {
if (!userId) return 0;
const snap = await followsRef.where("followerId", "==", userId).get();
return snap?.size || 0;
};
export const unfollowUser = async ({ followerId, followeeId }) => {
if (!followerId || !followeeId) throw new Error("Missing followerId/followeeId");
const id = `${followerId}_${followeeId}`;
await followsRef.doc(id).delete();
return id;
};