1. When New User Joins
- When New User Joins, he/she needs to signup it’s a regular process that everyone needs to follow
- Then now we’ll be fetching their “github_user_id” field as well.
- Let suppose if user changes their GitHub Username for some reason, login back to the RDS Site, then no new document will get created! Hence the bug has been fixed!
- For more clarification please refer the attached video:
2023-04-24 21-31-14.mp4
2. Migration Part
- I’ve created a post route:
- Initially the route was
router.patch("users/api/migrate", users.migrate);
This is the updated one, I’ve added the addition security as well
![Screenshot from 2023-05-09 14-59-19.png](https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4c99bb29-a2ac-447f-8d76-0d6728c90efd/Screenshot_from_2023-05-09_14-59-19.png)
- and created a function called migrate, this function will loop over all documents present inside the user collection of RDS and based on the “github_id”(which stores the username) of all the documents it will fetch “github_user_id”(which will store the unique id) field accordingly.
- Super user just need to run this route once!
- For more clarification please refer the attached video:
- Instead of updating each user one by one in a for loop, which can be inefficient when dealing with a large number of users in the database (more than 1000 users for our database). I used the batch update methodology you can see the below attached image, with this we can avoid rate limiting of Github Api.
Migration Explanation