firestore 는 noSQL 로 문서와 컬렉션이라는 개념이 있다
문서는 키-값 쌍의 자료형으로 각 문서는 고유 ID 가 있다
문서들의 집합이 컬렉션
SQL로 치면 컬렉션이 DB, 문서가 table 과 비슷한 느낌인것 같다
import firestore from '@react-native-firebase/firestore';
export const usersCollection = firestore().collection('users');
export function createUser({id, displayName, photoURL}) {
return usersCollection.doc(id).set({
id,
displayName,
photoURL,
});
}
export async function getUser(id) {
const doc = await usersCollection.doc(id).get();
return doc.data();
}
usersCollection 에서 add 메서드를 사용하면 firestore 에서 생성해주는 고유 아이디 값을
얻을 수 있다