'How to implement the Like button with Fire Store?

I want to implement the Like button and Dislike button using Firestore. I've already implemented login, and I think I'll have to create a user ID Set of people who pressed the like button or dislike and mark the number of likes or dislikes as the number of Set's elements, but I don't know how to use Set in the Fire Store.



Solution 1:[1]

Sounds like this is an array within the "post" document. You can update an array like this:

https://cloud.google.com/firestore/docs/manage-data/add-data#update_elements_in_an_array

There's no way to query only the count of items in an array. Your options are:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 atultw