我不知道如何在Firebase返还给我的商店阵列中获得Firestsore文档(商店)ID的属类。
componentDidMount() {
let response = fire.firestore().collection('shops').
get().
then(snapshot => {
const data = snapshot.docs.map(doc => doc.data());
this.setState({
...this.state,
shopsArray: data
})
})
}
SwiftUI use relationship predicate with struct parameter in FetchRequest
答案 0 :(得分:1)
要获取文档ID,请使用DocumentSnapshot.id
property。像这样:
componentDidMount() {
let response = fire.firestore().collection('shops').
get().
then(snapshot => {
snapshot.docs.forEach((doc) => { console.log(doc.id); });
...