Migrate data to firebase firestore

This commit is contained in:
2019-03-03 12:18:49 +07:00
parent 9ec5708464
commit 22ae5f09d2
4 changed files with 57 additions and 168 deletions

View File

@@ -12,6 +12,7 @@
</template>
<script>
import Vue from 'vue';
import BookPartContent from '@/components/Article/Part/Content';
import BookPartWords from '@/components/Article/Words';
@@ -26,15 +27,25 @@
required: true,
},
},
computed: {
part() {
return this.$store.getters.getParts.find(part => part.articleId === this.articleId
&& part.articlePartId === this.partId);
}
},
components: {
BookPartContent,
BookPartWords,
},
data: () => ({
part: null,
}),
created() {
Vue.$db.collection('articleParts')
.where('articleId', '==', this.articleId)
.where('articlePartId', '==', this.partId)
.get()
.then((querySnapshot) => {
const snapDocs = querySnapshot.docs;
if (snapDocs.length > 0) {
this.part = Object.assign({}, snapDocs[0].data());
}
})
.catch(e => console.error(e));
}
};
</script>