I want to make a small project using react js in which one can sign up/ sign in and then make a post on the web app. I have made the authentication component, but I have trouble displaying only the posts that were made by the logged user. (currently, it shows all posts from the database)
My current db is like this:
user
????-email
????-displayName
post
????-text
????-image
My current approach was the following, where db is:
db = firebaseApp.firestore();
for the posts:
db.collection("posts").add({
text: message,
image: media
});
and for the users:
db.collection("users").add({
email: email
});
I was thinking of changing the db structure, like so:
user
????-email
????-displayName
????-text1
????-image1
????...
However, it is not possible to dynamically set the keys' names, and I don't know how I can store the post and then access it via code.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…