After creating a new database in PostgreSQL, I needed to connect my Node/Express application to my database. I decided to use node-postgres to do this. I followed the recommended setup for node-postgres and created a new db folder with an index.js file setting up my PostgreSQL database. After quickly testing to ensure that I was connected to the database, I began the process of updating my routes to reflect the new database.
ReadAs I continued to restructure my database to accommodate user authentication, I ran into several issues. I solved some of these problems using embedded documents and aggregation. However, as I continued to learn more about databases, I came to an important realization: I misunderstood the relationships within the data I created; I incorrectly identified various relationships within my database as one-to-many.
ReadAfter restructuring my database to accommodate user authentication, I was faced with a new challenge: displaying and manipulating information from arrays.
ReadAfter adding user authentication, I had three separate schemas for my application: a user schema, a video schema, and a list schema (that referenced videos created using the video schema). After creating an account and logging in, users could see any video or list that any user had created. However, users should have only been able to see the videos and lists that they themselves added. I had to create some sort of relationship between the user and videos and lists of videos.
ReadOne of the features many TikTok users, including myself, would like to have is the ability to search for or sort videos according to when they were uploaded. This information is not included in the official TikTok API, so I assumed that it was not available. However, I recently read a very helpful post from Digital Forensics that detailed how to get timestamps from TikTok videos. I decided to implement the steps in Node.js and append this information to videos saved in the database.
ReadOne of the most important functions for my TikTok bookmark app is the ability to import an entire list of liked videos. During the process of testing files for liked videos, I realized that longer lists (with thousands of videos) struggled to import all files in one attempt. After examining 150 videos or so, I started receiving error messages about the connect timing out. I fiddled with the asynchronous code I created (and upgraded the for loop I was using to an ES6 for...of loop in the process), but I continued to see the same error messages after a minute or so of processing HTTP get requests.
ReadLongtime users of TikTok will have probably liked hundreds, if not thousands, of videos on the app. It would be incredibly tedious for a user to select each video, click its share icon, copy a link, and then submit data its URL data. Thankfully, TikTok allows users to download all of their data, including their list of Liked videos. The user receives this information as a text file called Like List.txt.
Read