mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 02:08:47 +00:00
Added basic backend implementation to get posts based on topics
This commit is contained in:
parent
51fb554133
commit
bf0c4c78ee
@ -41,3 +41,20 @@ exports.getallPostsforUser = (req, res) => {
|
||||
return res.status(500).json({error: 'Failed to fetch all posts written by specific user.'})
|
||||
})
|
||||
}
|
||||
|
||||
exports.getallPostsrelatedtoTopics = (req, res) => {
|
||||
admin.firestore().collection('posts').where('microBlogTopics', '==', 'Joker').get()
|
||||
.then((data) => {
|
||||
let posts = [];
|
||||
data.forEach(function(doc) {
|
||||
posts.push(doc.data());
|
||||
});
|
||||
return res.status(200).json(posts);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.err(err);
|
||||
return res.status(500).json({error: 'Failed to fetch all posts with a specific Topic.'})
|
||||
}
|
||||
|
||||
)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user