I want to save a value inside a field in firestore, like this image.
As you can see in the picture, I want shopId to be dynamic, then it will contain date and time fields with a boolean value.
My objective is to track a user's Checkin history on different shops. Hope you understand what i'm saying here.
now this is my current code:
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!`);
});
}
};
Is this possible to firestore?