My current Structures looks like this
Collection Posts
- PostID
- titel
- content
- titelimgurl
- tags
- timestamp
Now getting the Data here is easy, what I wanna achieve is splitting up the Content from the Rest so that I dont have to fetch unneeded data on my frotnpage.
So I plan to go for this structure:
Collection Posts
- PostID
- titel
- titelimgurl
- tags
- timestamp
Collection Content
- PostID
- content
The problem is that Im not sure how to retrieve the data efficiently there for example:
var postRef = db.collection("posts").doc(this.docID);
postRef.get().then(function(doc) {
if (doc.exists) {
var contentRef = db.collection("content").doc(doc.id)
contentRef.get().then(function(doc) {
....
}
} else {
// doc.data() will be undefined in this case
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
});
This looks overly complicated specially when assigning this data to an actual collection of posts in my Store, any ideas appreciated on how I can make this more efficient.