RealDevSquad / RealDevSquad/website-backend
[RFC] Generating auto incrementing sequence for task number
@YashJain24-chief is already working on this.
Since Nov 5, 2022.
- Dominant language
- JavaScript
- Stars
- 74
- Forks
- 276
- Avg merge
- 1d 26m
- Merged PRs (30d)
- 14
Description
https://github.com/Real-Dev-Squad/todo-action-items/issues/77
Approach 1
When a new task is created, update the counter by reading from and writing to the taskCounter collection that will store the previous value of the counter.
Pros
- Lesser number of reads and writes as we have a separate collection. Basically, only 1 read for getting the previous value and 1 write for updating the value in collection everytime a new task is created.
Cons
- Creating a whole new collection just for storing the previous counter value
- Two operations are performed - Reading the old counter value and then using it to increment the value and storing back to the taskCounter collection.
Approach 2
Getting QuerySnapshot of the task collection and using size property
Pros
- No need to maintain a collection just to maintain a single count value. Good for medium-sized collections that contain around 100-1000 documents.
Cons
- The main problem is the cost, by executing this query we will be charged for one read for each doc of the sub-collection.
Approach 3
Using the count aggregation query.
Pros
No need to read and write to the firestore every time. It will basically return the number of documents in a collection which can then be incremented and stored when a new task is created. We are charged a small number of reads for a large number of matched entries.
Cons
If a count() aggregation cannot resolve within 60 seconds, it returns a DEADLINE_EXCEEDED error. Performance depends on the size of the dataset.
Also what happens to the tasks that are already in the DB? How do we have a task number for those tasks?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.