【发布时间】:2019-04-18 10:12:20
【问题描述】:
async componentDidMount() {
firebase.firestore().collection('profiles').get().then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
var data = doc.data().pushToken; // I'm able to fetch pushToken here.
const profileRef = firebase.firestore.doc(`profiles/0bT9eZ42CNN1uQYAE728WJht2aO2`)
.collection('private').doc('pushToken');
profileRef.set(data, {
merge: true
}).catch(e => console.error(e));
});
})
.catch(function(error) {
alert("error"); // My .then function throws an error and hence this alert works
console.log("Error getting documents: ", error);
});
}
我希望能够从每个文档的字段中获取pushToken,然后插入到同一个文档中名为private 的集合中。
但它给了我一个错误说
获取文档时出错:TypeError: _reactNativeFirebase2.default.firestore.doc 不是函数
如何将pushToken 移动到收藏夹?我想自动而不是手动地在每个文档中创建集合。
【问题讨论】:
标签: javascript firebase react-native google-cloud-firestore