Firestore

users collection의 각 유저의 팔로잉 목록을 collection으로 만들기 위해 아래와 같이 시도했다. await setDoc(doc(db, `users/${user.uid}/following`, userId), {}); 근데 안된다.... doc의 두번째 인자로 document를 만드려는 collection의 경로를 한 번에 주면 되는 줄 알았는데 아니었다. 그래서 구글링으로 아래의 방법을 찾아냈다. https://stackoverflow.com/questions/72132896/firebase-firestore-add-document-to-sub-collection-version-9 Firebase / Firestore Add Document to Sub collection Version..
문제 현재 트윗을 보여줄 때 트윗을 게시한 사람의 프로필 사진도 보인다. 이렇게 구현하기 위해 트윗이 마운트될 때 트윗을 게시한 사람의 정보를 갖고 오도록 아래와 같이 함수를 만들어 useEffect에 넣었다. // Name 가져오기 const getName = async () => { const docRef = await getDoc(doc(db, "users", userId)); setName(docRef.get("userName")); }; // 프로필 사진 가져오기 const getProfilePhoto = async () => { const fileRef = ref(storage, `avatars/${userId}`); try { await getDownloadURL(fileRef).then((..
회원가입할 때 사용자 정보를 firestore에 document로 저장하려고 했는데 Missing or insufficient permissions. 이런 에러가 뜨며 document가 생성되지 않았다. 원인을 찾아보니 firestore 규칙 때문인것 같다. firestore의 규칙으로 가서 확인해보자. 로그인하지 않은 사용자는 firestore에서 create를 할 수 없게 아래와 같이 규칙을 설정해놨었다. 그런데 회원가입할 때 firestore에 document를 create하려고 하니 에러가 난 것이다.  해결하는 방법으로는allow read, write: if true; 이렇게 모든 권한을 허용해주는 방법도 있지만 이건 아무나 API키만 안다면 나의 firestore에 접근하여 사용할 수 있는 것..
딜레이레이
'Firestore' 태그의 글 목록