【发布时间】:2018-01-31 08:12:25
【问题描述】:
我想在 firestore 的字段中保存一个值,就像这张图片一样。
正如您在图片中看到的,我希望 shopId 是动态的,然后它将包含带有布尔值的日期和时间字段。
我的目标是跟踪用户在不同商店的签到历史记录。希望你明白我在说什么。
现在这是我当前的代码:
checkInShop() {
let currentUser = firebase.auth().currentUser;
if (currentUser) {
const db = firebase.firestore();
const batch = db.batch();
const docRef = db.collection("userCheckInHistory").doc(currentUser.uid);
const timestamp = firebase.firestore.FieldValue.serverTimestamp();
batch.set(docRef, {
`${this.state.shopId}`: {
`${timestamp}`: true
}
});
// Commit the batch
batch.commit().then(function() {
AlertIOS.alert(`ShopId: Sent!`);
});
}
};
这可以火存储吗?
【问题讨论】:
标签: object react-native google-cloud-firestore