Code for removing user from db still in progress (commented out)

This commit is contained in:
Aaron Sun
2019-10-24 15:27:20 -04:00
parent 45f88861c8
commit eea2f56b49
3 changed files with 44 additions and 31 deletions

View File

@@ -15,29 +15,28 @@ exports.putPost = (req, res) => {
};
admin.firestore().collection('posts').add(newPost)
.then((doc) => {
const resPost = newPost;
resPost.postId = doc.id;
return res.status(200).json(resPost);
})
.catch((err) => {
console.error(err);
return res.status(500).json({ error: 'something is wrong'});
});
.then((doc) => {
const resPost = newPost;
resPost.postId = doc.id;
return res.status(200).json(resPost);
})
.catch((err) => {
console.error(err);
return res.status(500).json({ error: 'something is wrong'});
});
};
exports.getallPostsforUser = (req, res) => {
admin.firestore().collection('posts').where('userHandle', '==', 'new user' ).get()
.then((data) => {
let posts = [];
data.forEach(function(doc) {
posts.push(doc.data());
});
return res.status(200).json(posts);
})
.catch((err) => {
console.error(err);
return res.status(500).json({error: 'Failed to fetch all posts written by specific user.'})
})
}
.then((data) => {
let posts = [];
data.forEach(function(doc) {
posts.push(doc.data());
});
return res.status(200).json(posts);
})
.catch((err) => {
console.error(err);
return res.status(500).json({error: 'Failed to fetch all posts written by specific user.'})
})
};