Answer the question
In order to leave comments, you need to log in
How to get _unsolved tasks first in firebase?
I have a site with tasks. I use Firebase to store everything.
Tasks are stored in the tasks collection.
When I click on a button, I want to receive a task from those that I have not yet solved.
How to properly organize the database structure so that this is possible?
Each task can be solved by one user, but not solved by another.
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
Add a flag for each task whether it is solved or not, for example, name it solved, let 1 mean solved, 0 - not solved (true and false did not work correctly some time ago, so it’s better to use numerical values just in case). And when accessing the collection, indicate that you want to get only those that are not solved (that is, those that have solved = 0) through equalTo. More about equalTo here . The structure, respectively, will be:
tasks
taskKey1
taskID
taskName
solved
...
taskKey2
taskID
taskName
solved
....
I would do this would create a key with tasks then the user id and notice 2 keys newTasks and doneTasks.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question