From 4b440d28de160b125e8da698c5bf8b0f1f8d8e83 Mon Sep 17 00:00:00 2001 From: Aaron Sun Date: Fri, 29 Nov 2019 20:17:21 -0800 Subject: [PATCH] Fixed a small bug in sorting userline posts --- functions/handlers/post.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/handlers/post.js b/functions/handlers/post.js index 8ee0bd1..07654c4 100644 --- a/functions/handlers/post.js +++ b/functions/handlers/post.js @@ -29,12 +29,14 @@ exports.putPost = (req, res) => { }; exports.getallPostsforUser = (req, res) => { - var post_query = admin.firestore().collection("posts").where("userHandle", "==", req.user.handle); + var post_query = admin.firestore().collection("posts");//.where("userHandle", "==", req.user.handle); post_query.orderBy('createdAt', 'desc').get() .then(function(myPosts) { let posts = []; myPosts.forEach(function(doc) { - posts.push(doc.data()); + if(doc.data().userHandle === req.user.handle) { + posts.push(doc.data()); + } }); return res.status(200).json(posts); })