{"id":1734,"date":"2024-11-26T21:59:19","date_gmt":"2024-11-26T13:59:19","guid":{"rendered":"https:\/\/www.tonghin.com.my\/blog\/?p=1734"},"modified":"2024-11-26T21:59:21","modified_gmt":"2024-11-26T13:59:21","slug":"internship-week-6-mongodb-synchronisation-and-testing","status":"publish","type":"post","link":"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/","title":{"rendered":"Internship (Week 6): MongoDB synchronisation and testing"},"content":{"rendered":"\n<p>On the first day, Mr. Peter had provided me several Docker commands for running Mongo Express with different replica sets. After executing the commands, I am able to login the Mongo Express. I then create some databases for users and stores along with their respective collections. Meanwhile, based on the provided &#8220;stores&#8221; files, I reference it to create users and subsequently build and update the contexts, repositories, services, interfaces and commands. Initially, I populate the MongoDB with sample user data after updates the Mongo connections of environment. I then create a controller and try to get all the user data created. However, there are some issues since the Object value is in different format with &#8220;timestamp&#8221; and &#8220;creationTime&#8221;. So I use ToString function in order to retrieve data in string value, and I successfully read all the user data. <\/p>\n\n\n\n<p>After that, Mr. Peter emphasised that the users in MongoDB should be checked against all system databases so that there will be no extra users for new user creation when synchronising. Moreover, I consult with Mr. Peter for a clearer understanding of the concepts discussed yesterday. His clarification helped immensely that I need to retrieve all data and merge them to avoid overlaps, and then compare with MongoDB data to check the users existence before deletion. Then, I continue the manual synchronisation process of creating and updating data and the deleting in MongoDB. However, I face challenges while trying to merge user data. So I do searching about this scenario and understand how to union the data to remove redundant users from MongoDB. As all the manual synchronising successfully, the sense of accomplishment I feel after solving this is very motivating.<\/p>\n\n\n\n<p>Additionally, I move on to mock testing using the &#8220;stores&#8221; files as references. I encounter an issue while initialising the MongoDB data and try various approaches without success. After discussing it with my colleague, she then provided some useful code snippets that helped me understand the process better. Despite this, I still face difficulties that I couldn&#8217;t get the initialised data. Upon consulting Mr. Peter, he identified that the issue was due to using capital letters in the collection name instead of lowercase. Once corrected, everything worked smoothly. In addition, I continue with my testing and fortunately, all the tests passed successfully. <\/p>\n\n\n\n<p>I then update the synchronisation command for the warehouse MongoDB connection, and create another controller to call user data from MongoDB. By reusing the existing code for the retail sync, I could just making minor adjustments which help streamline the process. I successfully sync data from MongoDB to create new users, although I realize later that I had missed implementing the update functionality for changes in MongoDB. I plan to address this the next day. Meanwhile, I refine the mock testing environment for the warehouse and test the original code with initialized data, which worked successfully. Mr. Peter and I also discuss changes in MongoDB collection naming and connection settings.<\/p>\n\n\n\n<p>Mr. Peter requested updates to the user and store contexts for their respective databases. After making the updates and testing them successfully, I proceed with synchronising the other data. The mock testing for sync commands also went well. However, I face challenges when implementing create, update and delete operations due to service issues. Despite adding scopes to the relevant interfaces and repositories, I couldn&#8217;t resolve the problem. After consulting Mr. Peter again proved helpful, as he discovered that a persistence configuration was missing during startup. Once fixed, everything functioned as expected. Meanwhile, he suggested using either the override or base method for my logic, which I plan to tackle next week. <\/p>\n\n\n\n<h4>Conclusion<\/h4>\n\n\n\n<p>This week was a valuable learning experience filled with challenges, problem-solving and significant progress. Each day presented new tasks that deepened my understanding of MongoDB, synchronisation processes and testing environments. I learn a lot and feel a sense of achievement after overcoming each obstacle. The journey reinforced the importance of patience, attention to detail and continuous learning. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>On the first day, Mr. Peter had provided me several Docker commands for running Mongo Express with different replica sets. After executing the commands, I am able to login the Mongo Express. I then create some databases for users and stores along with their respective collections. Meanwhile, based on the provided &#8220;stores&#8221; files, I reference &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Internship (Week 6): MongoDB synchronisation and testing&#8221;<\/span><\/a><\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Internship (Week 6): MongoDB synchronisation and testing<\/title>\n<meta name=\"description\" content=\"Each day presented new tasks that deepened my understanding of MongoDB, synchronisation processes and testing environments\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Internship (Week 6): MongoDB synchronisation and testing\" \/>\n<meta property=\"og:description\" content=\"Each day presented new tasks that deepened my understanding of MongoDB, synchronisation processes and testing environments\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/\" \/>\n<meta property=\"og:site_name\" content=\"Tong Hin&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-26T13:59:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-26T13:59:21+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"3 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\",\"name\":\"TONG HIN MACHINERY\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"sameAs\":[\"https:\/\/www.youtube.com\/channel\/UC60EoxJMNbu8mV0LuEGfrBg\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/wp-content\/uploads\/2020\/10\/web_logo_180_180.jpg\",\"width\":180,\"height\":180,\"caption\":\"TONG HIN MACHINERY\"},\"image\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Tong Hin&#039;s Blog\",\"description\":\"Sharing About Technology\",\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.tonghin.com.my\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/#webpage\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/\",\"name\":\"Internship (Week 6): MongoDB synchronisation and testing\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\"},\"datePublished\":\"2024-11-26T13:59:19+00:00\",\"dateModified\":\"2024-11-26T13:59:21+00:00\",\"description\":\"Each day presented new tasks that deepened my understanding of MongoDB, synchronisation processes and testing environments\",\"breadcrumb\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/\",\"name\":\"Internship (Week 6): MongoDB synchronisation and testing\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/fb4d75677cd7632e197b8b04dd488c68\"},\"headline\":\"Internship (Week 6): MongoDB synchronisation and testing\",\"datePublished\":\"2024-11-26T13:59:19+00:00\",\"dateModified\":\"2024-11-26T13:59:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/11\/26\/internship-week-6-mongodb-synchronisation-and-testing\/#webpage\"},\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"articleSection\":\"Experiential\",\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/fb4d75677cd7632e197b8b04dd488c68\",\"name\":\"Lee Wai Lun\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ddc37519924feb741e1cc09e5393f95c?s=96&d=mm&r=g\",\"caption\":\"Lee Wai Lun\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/1734"}],"collection":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/comments?post=1734"}],"version-history":[{"count":11,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/1734\/revisions"}],"predecessor-version":[{"id":1771,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/1734\/revisions\/1771"}],"wp:attachment":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/media?parent=1734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/categories?post=1734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/tags?post=1734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}