Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
add uid to each post
Browse files Browse the repository at this point in the history
  • Loading branch information
amandeepmittal committed Nov 16, 2019
1 parent 9d9c6e4 commit b3d8787
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/utils/Firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ const Firebase = {
.set(userData)
},
uploadPost: post => {
let user = firebase.auth().currentUser
const id = uuid.v4()
const uploadData = {
uid: user.uid,
id: id,
postPhoto: post.photo,
postTitle: post.title,
Expand All @@ -39,18 +41,23 @@ const Firebase = {
.set(uploadData)
},
getPosts: () => {
return firebase
.firestore()
.collection('posts')
.get()
.then(function(querySnapshot) {
let posts = querySnapshot.docs.map(doc => doc.data())
// console.log(posts)
return posts
})
.catch(function(error) {
console.log('Error getting documents: ', error)
})
let user = firebase.auth().currentUser
return (
firebase
.firestore()
.collection('posts')
// .where('uid', '==', user.uid)
.get()
.then(function(querySnapshot) {
let posts = querySnapshot.docs.map(doc => doc.data())
// console.log('CURRENT USER =======>', user)
// console.log(posts)
return posts
})
.catch(function(error) {
console.log('Error getting documents: ', error)
})
)
}
}

Expand Down

0 comments on commit b3d8787

Please sign in to comment.