follow users
This commit is contained in:
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user