<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Emmy Steven</title>
    <description>The latest articles on Forem by Emmy Steven (@emmysteven).</description>
    <link>https://forem.com/emmysteven</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F247951%2Fcb19cda6-4eb0-499a-8da0-ccb252d0cc3a.png</url>
      <title>Forem: Emmy Steven</title>
      <link>https://forem.com/emmysteven</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/emmysteven"/>
    <language>en</language>
    <item>
      <title>How This NuGet Package Almost Cost Me My Job</title>
      <dc:creator>Emmy Steven</dc:creator>
      <pubDate>Tue, 18 Jul 2023 15:29:13 +0000</pubDate>
      <link>https://forem.com/codaholic/how-this-nuget-package-almost-cost-me-my-job-2n7p</link>
      <guid>https://forem.com/codaholic/how-this-nuget-package-almost-cost-me-my-job-2n7p</guid>
      <description>&lt;p&gt;In the world of .NET development, NuGet packages have become an essential part of building applications. These are pre-built libraries that offer convenience and efficiency, enabling .NET developers to save time and effort by leveraging existing code. However, my personal experience with a particular NuGet package taught me a valuable lesson about the importance of thorough evaluation and careful implementation. In this blog post, I will share the story of how a seemingly harmless NuGet package nearly jeopardised my job and discuss the key takeaways and best practices to prevent similar pitfalls.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of Z.BulkOperations
&lt;/h3&gt;

&lt;p&gt;When I first encountered the Z.BulkOperations NuGet package, I was immediately drawn to its promising features and potential benefits for my project. This package specializes in efficient bulk data operations, offering a streamlined approach to handling large datasets within a database. With the package's reputation for improving performance and simplifying database operations, it seemed like the perfect solution to tackle the specific challenge I was facing in my project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsu3t0mho1evlpjh0h90.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsu3t0mho1evlpjh0h90.png" alt="Benefits of Z.BulkOperations" width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Enhanced Performance:&lt;br&gt;
One of the key attractions of the Z.BulkOperations package was its ability to significantly enhance performance when dealing with large volumes of data. The package leverages optimized bulk operations, enabling faster data processing and database interactions. This efficiency was particularly appealing as it promised to address performance bottlenecks that I had encountered in my project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Simplified Database Operations:&lt;br&gt;
Another compelling feature of Z.BulkOperations was its ability to simplify complex database operations. The package provided a high-level abstraction layer that allowed for seamless bulk inserts, updates, and deletes. This abstraction meant that I could streamline my code and reduce the number of database round trips, resulting in improved efficiency and code readability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Positive Reputation:&lt;br&gt;
The reputation of the Z.BulkOperations package within the developer community further heightened its appeal. It had garnered positive reviews and testimonials from developers who praised its performance and ease of use. The package's popularity and active community support gave me confidence that it was a reliable and well-maintained solution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Addressing Project Challenges:&lt;br&gt;
In my project, I was tasked with processing and manipulating a large dataset within a tight timeframe. The traditional approach of performing individual database operations for each record proved to be time-consuming and resource-intensive. This is where Z.BulkOperations appeared to offer an efficient alternative, enabling me to handle the dataset more effectively and meet project deadlines.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, as I would soon discover, the allure of the Z.BulkOperations package came with unexpected challenges and implications. Despite its attractive features, there were crucial factors that I overlooked during the initial evaluation, leading to severe consequences that nearly cost me my job. In the following sections, I will delve into these challenges and share the valuable lessons I learned from this experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Con of Z.BulkOperations
&lt;/h3&gt;

&lt;p&gt;On one faithful day, I resumed work as usual, and as a routine, I decided to go through my emails, only to see a mail with a screenshot of the error message that the frontend part of my application was throwing. The error message I was greeted with was "Something went wrong, please try again". I was thrown aback because this error should not be happening.&lt;/p&gt;

&lt;p&gt;So I tried reproducing the error on my local machine but I didn't see anything, the particular action the user was getting an error for on production was going successfully on my local machine.&lt;/p&gt;

&lt;p&gt;I had to look at the log file to get a sense of what was happening. Below is the image of what the error message was&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbv9v001aglqrxqknykwf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbv9v001aglqrxqknykwf.png" alt="Error Log" width="800" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I was surprised and at the same time, I felt relieved. I asked myself, how come I didn't see this?, it was obvious, I didn't thoroughly read the documentation.&lt;/p&gt;

&lt;p&gt;When I saw this NuGet Package online, I was only interested in knowing how to implement it and solve the particular challenge I had.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Was The Solution?
&lt;/h3&gt;

&lt;p&gt;The options before me were to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pay for the NuGet package&lt;/li&gt;
&lt;li&gt;Make use of &lt;code&gt;AddRangeAsync&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Make use of &lt;code&gt;SqlBulkCopy&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since I was not willing to pay $300 for this NuGet extension or package, I decided to uninstall it, so I was left with options 2 and 3. I decided to use &lt;code&gt;SqlBulkCopy&lt;/code&gt; which is the third option.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use SqlBulkCopy
&lt;/h3&gt;

&lt;p&gt;The reason I didn't go for the second option was that if for example, I want to insert 100 rows into a table, I'll have to hit the database 100 times, performance-wise, this is a deal breaker. So with &lt;code&gt;SqlBulkCopy&lt;/code&gt;, I'll only have to hit the database only once regardless of the number of rows I'll need to insert.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IEnumerable&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;CreateAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TimerDto&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;timers&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_mapper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IEnumerable&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Timer&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Timers&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;ToList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;dataTable&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;dataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Columns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
        &lt;span class="n"&gt;dataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Columns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
        &lt;span class="n"&gt;dataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Columns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Start"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
        &lt;span class="n"&gt;dataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Columns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"End"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

        &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;timer&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;timers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;dataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;End&lt;/span&gt;
            &lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;sqlBulkCopy&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;SqlBulkCopy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Database&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetDbConnection&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;ConnectionString&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;sqlBulkCopy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DestinationTableName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"[codaholic].[dbo].[Timer]"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;sqlBulkCopy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteToServerAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dataTable&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;timerIds&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;timers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IEnumerable&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;timerIds&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is a simple explanation of what the code above does, a &lt;code&gt;DataTable&lt;/code&gt; is created to hold the timer data. Columns are added to the &lt;code&gt;DataTable&lt;/code&gt; to match the properties of the Timer entity, such as &lt;code&gt;Id&lt;/code&gt;, &lt;code&gt;Name&lt;/code&gt;, &lt;code&gt;Start&lt;/code&gt;, and &lt;code&gt;End&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;foreach&lt;/code&gt; loop iterates over the timers list and adds each timer's data as a new row in the &lt;code&gt;DataTable&lt;/code&gt;. Each timer's properties are accessed and added to the corresponding columns in the &lt;code&gt;DataTable&lt;/code&gt;.&lt;br&gt;
SqlBulkCopy:&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;SqlBulkCopy&lt;/code&gt; object is created, using the connection string from the _context object's database connection. This object facilitates the bulk insert operation into the database.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;DestinationTableName&lt;/code&gt; property is set to specify the destination table where the data should be inserted.&lt;br&gt;
The &lt;code&gt;WriteToServerAsync&lt;/code&gt; method is called to perform the bulk insert operation asynchronously, using the &lt;code&gt;DataTable&lt;/code&gt; as the source of the data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;By sharing my cautionary tale, I hope to raise awareness among developers about the potential risks of blindly adopting NuGet packages. Through careful evaluation, taking time to read the documentation, and not just getting a bunch of code from StackOverflow or ChatGPT, we can mitigate the chances of encountering similar issues and ensure a more stable software development process.&lt;/p&gt;

</description>
      <category>dotnetcore</category>
      <category>nuget</category>
      <category>coding</category>
      <category>programming</category>
    </item>
    <item>
      <title>If-Else Vs Switch-Case</title>
      <dc:creator>Emmy Steven</dc:creator>
      <pubDate>Sat, 25 Mar 2023 21:45:11 +0000</pubDate>
      <link>https://forem.com/emmysteven/if-else-vs-switch-case-16fe</link>
      <guid>https://forem.com/emmysteven/if-else-vs-switch-case-16fe</guid>
      <description>&lt;p&gt;Before I did my research on this post, I use if-else with reckless abandon 😂, however, what matters as one progresses in software engineering is not just writing code that works but writing code that is efficient.&lt;/p&gt;

&lt;p&gt;A times comes in one's career, where you move from the know-how to the know-why.&lt;/p&gt;

&lt;p&gt;Enough of my ted talk, let's dive into the topic of discussion.&lt;/p&gt;

&lt;p&gt;"if-else" and "switch-case" are both conditional statements in programming that allows for the execution of different code blocks based on different conditions.&lt;/p&gt;

&lt;p&gt;"if-else" statements can be used to evaluate Boolean expressions or comparison operators, hence, they're suitable for complex conditions and also for cases where the number of conditions is not known in advance.&lt;/p&gt;

&lt;p&gt;"switch-case" statements are typically used with discrete values, such as enums or integer values, and allow for cleaner and more concise code. However, switch-case statements are less flexible and cannot handle complex conditions.&lt;/p&gt;

&lt;p&gt;Here's the question, How do you when to use "if-else" or "switch-case" statements?&lt;/p&gt;

&lt;p&gt;Use if-else when:&lt;br&gt;
» The condition to be evaluated is complex or involves multiple comparison operators&lt;br&gt;
» The number of conditions to evaluate are small&lt;br&gt;
» The conditions are not based on discrete values&lt;/p&gt;

&lt;p&gt;Use switch-case when:&lt;br&gt;
» The condition to be evaluated is based on a discrete value, such as an enum or integer value&lt;br&gt;
» The number of conditions to evaluate are large&lt;br&gt;
» The conditions are simple and can be expressed as equality tests&lt;/p&gt;

&lt;p&gt;Knowing what conditional statement to use will help you move from writing code that works to writing efficient code.&lt;/p&gt;

&lt;p&gt;Which of these conditional statements do you use? 🤔&lt;/p&gt;

&lt;p&gt;kyrios Iesous&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>Things I Wished I Did Before Applying For Tech Jobs</title>
      <dc:creator>Emmy Steven</dc:creator>
      <pubDate>Wed, 11 Jan 2023 23:49:44 +0000</pubDate>
      <link>https://forem.com/emmysteven/things-i-wished-i-did-before-applying-for-tech-jobs-163b</link>
      <guid>https://forem.com/emmysteven/things-i-wished-i-did-before-applying-for-tech-jobs-163b</guid>
      <description>&lt;p&gt;With the massive layoffs in the tech space, getting into tech can be a daunting task. Truth be told it is a lot hard for newbies to get job in Tech, and here are the things I wish I knew before applying for tech jobs.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Apply to companies you can move up with or grow in, i.e you can apply as I.T Support, but have the game plan to move to software engineering in the same company. You may be surprised to learn that you may not have to do DSA tests and whiteboard tests, you may only need to do some behavioral test and show some projects that you've done.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make a list of 10 to 20 companies you want to work with, start with the most wanted to the least wanted. Start applying to the least wanted company and work your way up, this will allow you gain experience in the interview process and know what they are looking for. Another reason you start with the least wanted company is that you don't get devastated if you get rejected unlike when you start with the most wanted company.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do some freelance work and get reviews from your client, this is can be on UpWork or Fiverr. This is a nice way to show that you've got some sort of experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Find an internship that pays good. Do internships for big companies, don't do internship for startups or midsize companies. For internship is either you go hard or go home. Don't just take internship for just any company.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Find 10 to 20 companies you'll love to work for and build a relationship with employees before you apply. You get to learn to pass interview through this people. You may or may not get a referral through this people.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you are a bootcamp graduate, the first thing you will want to do is to apply to that bootcamp as a learner assistant, because in your first tech job, they get to look for any technical thing that you've done.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Apply to startups, this is a great niche for developers. They don't really care where you are based in. As long as you can do the job, you are good to go.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Join and contribute to open source, they are a lot of people who have gotten employed by joining open source or who got their work noticed. It's always a win-win, you don't get to lose, you can get jobs easily using this method. Contribute frequently to open source.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Join Hackathons, a lot of companies organize hackathons, it is a nice way to meet people and network and you get to build your coding skills and also land a job.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go to meetups and/or organise meetups. If you don't have a meetup in your city, create one. It is nice having to be with a group of people that have the same passion and aspiration as you. You get to equally network with people and also get to land a job.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send cold mails using Clearbit. Clearbit is a gmail extension that helps you find any email in less than 5 seconds. This way you can do a cold outreach to the companies you want to work with.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Apply through stacking agencies if you have some in your area, the rejection rate is low, turn around time is low, and they let you know what the client wants or don't want. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you are in U.S apply to companies that are always employing those who are self taught developers or bootcamp graduates. You literally just have to do some DSA test and viola, you are employed. Walmart is a very good example.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What if do all the above and nothing seems to be working for you, create a course or create coding tutorials on YouTube. If you don't feel comfortable showing your face, you can create a blog or podcast.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a community where you can provide value and showcase the value you've provided. You can find after-school programs where you can go and teach teenagers how to code. Focus on things like this and you'll be amazed at the results it will bring to you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build in public with a purpose, don't build in build in public just to showcase your new project, it is ok to do so if that is what you want to do. But if you want to land a job, build in public with that goal in mind and showcase what you've built in public to the relationships you've built on LinkedIn and meetups so that they can easily refer you to their companies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Learn how to apply properly. A very good way to apply and is to make use of "easy apply" on LinkedIn. If you apply this way you don't get to burn yourself out. Another way of applying easily is to apply through Indeed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do DSAs on YouTube or twitch. You can do a youtube video of one DSA problem that you've done on HackerRank. You can leave it recorded if it's on Twitch, this can help you get a job. The reason for these is because without a proof it can be really difficult to land a job.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do not apply to less than 10 jobs in a week. Getting a tech job is really a game of numbers, doing less than 10 job applications will do you no good.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Research the company you want to have an interview with. Doing so will help you learn about the interview process. You can make use of LinkedIn or Glassdoor for this. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>programming</category>
      <category>webdev</category>
      <category>jobs</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The Dangerous Loop</title>
      <dc:creator>Emmy Steven</dc:creator>
      <pubDate>Mon, 20 Apr 2020 20:42:03 +0000</pubDate>
      <link>https://forem.com/emmysteven/the-dangerous-loop-41je</link>
      <guid>https://forem.com/emmysteven/the-dangerous-loop-41je</guid>
      <description>&lt;p&gt;As Software Engineers we all know what loops are. This post is about a special kind of loop - The Learning Loop. Almost every new Software Engineer trying to learn programming will come across this phase in his or her programming pathway. Yes this loop is dangerous, please try not to get stuck in it.&lt;/p&gt;

&lt;p&gt;Yes we all love to learn new stuff in tech, Yeah I agree it's cool, but binging online courses like Netflix series is not the way to do it. It's not going to be beneficial to you.&lt;/p&gt;

&lt;p&gt;Once you have learned a programming language. You are no longer a newbie in some sense. You can and you should start building something as soon as possible. Maybe a simple application to calculate something, or just use your skills to light up some LEDs using an arduino.&lt;/p&gt;

&lt;p&gt;You should take your time and build something with the knowledge you gained before moving on to a new technology. Find your interests and please stay focused.&lt;/p&gt;

&lt;p&gt;Now that a lot of platforms are offering their programming courses for free to help people during this pandemic, I've seen a lot people taking courses over and over. There are even folks whose hobby are completing online courses. At the end of the day they learn something a thing or two about those technologies but they have no practical knowledge in what they've learnt. they haven't built anything in it. Never be like them.&lt;/p&gt;

&lt;p&gt;Learn something, build something. Learn and Build that should be your slogan as an entry level Software Engineer.&lt;/p&gt;

</description>
      <category>firstyearincode</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Solved! Mongoose Unique Index Not Working</title>
      <dc:creator>Emmy Steven</dc:creator>
      <pubDate>Thu, 30 Jan 2020 02:23:49 +0000</pubDate>
      <link>https://forem.com/emmysteven/solved-mongoose-unique-index-not-working-45d5</link>
      <guid>https://forem.com/emmysteven/solved-mongoose-unique-index-not-working-45d5</guid>
      <description>&lt;p&gt;I was working on a project for an organisation I volunteer for, I encountered some difficulties in making the &lt;strong&gt;email&lt;/strong&gt; field in my database schema to be unique, below is a sneak peek into my database schema, it's a typical database schema anyway.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mongoose&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Schema&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;unique&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Schema&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;fname&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;lname&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;unique&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;timestamps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toDateString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;UserSchema&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and when I started my server and did my API test using Paw (REST Client like Postman), I found out that I could enter the same email again and again and that was not what I wanted.&lt;/p&gt;

&lt;p&gt;I went to Google as usual to seek solution to this abnormality, here are the thing I tried that didn't work:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Restarting MongoDB&lt;br&gt;
and then doing the following:&lt;br&gt;
mongo mydb&lt;br&gt;
db.users.reIndex()&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;when this one above did no work out, I this one below&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;UserSchema.index({ username: 1, email: 1 }, { unique: true});&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;when this one too didn't work, I was also asked to do modify my code with this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;uniqueValidator&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mongoose-unique-validator&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;// UserSchema = Schema({}) etc...&lt;/span&gt;

&lt;span class="nx"&gt;UserSchema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;plugin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uniqueValidator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
javascript&lt;/p&gt;

&lt;p&gt;I didn't do this because I felt so uncomfortable using a plugin to enforce a unique constraint on a particular field.&lt;/p&gt;

&lt;p&gt;I really don't know why the aforementioned solutions didn't work for me at all. However, I stumbled upon a solution that did the magic, and I think this method is the best approach in my opinion.&lt;/p&gt;

&lt;p&gt;I had to do this at the connection level:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dotenv/config&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mongoose&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;useNewUrlParser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;useCreateIndex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;autoIndex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;//this is the code I added that solved it all&lt;/span&gt;
  &lt;span class="na"&gt;keepAlive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;poolSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;bufferMaxEntries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;connectTimeoutMS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;socketTimeoutMS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;45000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Use IPv4, skip trying IPv6&lt;/span&gt;
  &lt;span class="na"&gt;useFindAndModify&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;useUnifiedTopology&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_URI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;gt; Successfully connected to DB&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;// syntactic sugar for { db: db }&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;what happens when you add&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;audoIndex: true&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 is that when you run your code it will create empty collection(s) and the corresponding index(es) which won't happen if you didn't add it.&lt;/p&gt;

&lt;p&gt;MongoDB together with Mongoose can be pretty weird&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>mongoose</category>
      <category>database</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How not to configure MongoDB on Docker</title>
      <dc:creator>Emmy Steven</dc:creator>
      <pubDate>Fri, 03 Jan 2020 09:48:45 +0000</pubDate>
      <link>https://forem.com/emmysteven/how-not-to-configure-mongodb-on-docker-nbn</link>
      <guid>https://forem.com/emmysteven/how-not-to-configure-mongodb-on-docker-nbn</guid>
      <description>&lt;p&gt;Just as Thomas Edison made 999 attempts in inventing the the lightbulb and then said He discovered 999 ways a lightbulb could not be made. This post is about how I discovered how not to configure MongoDB on Docker.&lt;/p&gt;

&lt;p&gt;I was working on my portfolio website, and I decided to use MongoDB on docker to just test out my knowledge on Docker since I have used PostgreSQL on Docker and it worked without any hassle.&lt;/p&gt;

&lt;p&gt;this is the content of my initial docker-compose.yml file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3.7'&lt;/span&gt;

&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;mongo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongo:4.0.4"&lt;/span&gt;
    &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongo"&lt;/span&gt;
    &lt;span class="na"&gt;env_file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;.env&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;MONGO_INITDB_ROOT_USERNAME:${USER}&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;MONGO_INITDB_ROOT_PASSWORD:${PASS}&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;MONGO_INITDB_DATABASE:${DB}&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./db/:/data/db/&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;27017:27017"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I fired up my terminal into the directory where my docker-compose.yml file was saved and did this:&lt;/p&gt;

&lt;p&gt;docker-compose up -d&lt;/p&gt;

&lt;p&gt;I waited for it to pull the mongo image and then build and start MongoDB as a service.&lt;/p&gt;

&lt;p&gt;Then I did the following to see if I could connect,&lt;/p&gt;

&lt;p&gt;docker exec -it mongodb bash&lt;br&gt;
mongo -u admin -p&lt;/p&gt;

&lt;p&gt;I enter the password on the password prompt, lo and behold I was denied access, for about 8 hours I battle with this issue, I went to stackoverflow, github and other website seeking for solution and I didn't find any.&lt;/p&gt;

&lt;p&gt;Then I decided to do what I normally do when I install mongodb on my local machine. In order to do that, I stopped the containers on my terminal and ran this command:&lt;/p&gt;

&lt;p&gt;docker-compose stop &amp;amp;&amp;amp; docker-compose down&lt;/p&gt;

&lt;p&gt;Then I edited my configuration to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3.7'&lt;/span&gt;

&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;mongo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongo:4.0.4"&lt;/span&gt;
    &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongo"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./db/:/data/db/&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;27017:27017"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I ran the following commands on my terminal:&lt;/p&gt;

&lt;p&gt;docker-compose up -d&lt;br&gt;
docker exec -it mongodb bash&lt;br&gt;
mongo&lt;/p&gt;

&lt;p&gt;and then, I was greeted with an interactive shell for mongodb and then I ran the following commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="nx"&gt;admin&lt;/span&gt;

&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;

 &lt;span class="p"&gt;{&lt;/span&gt;

 &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

 &lt;span class="na"&gt;pwd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;yourpassword&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

 &lt;span class="na"&gt;roles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;userAdminAnyDatabase&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;readWriteAnyDatabase&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

 &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;followed by this other command too&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="nx"&gt;your_db_name&lt;/span&gt;

&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;

 &lt;span class="p"&gt;{&lt;/span&gt;

 &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your_username&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

 &lt;span class="na"&gt;pwd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your_password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

 &lt;span class="na"&gt;roles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;readWrite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your_db_name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}]&lt;/span&gt;

 &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;viola! that's what solved the problem I was encountering.&lt;/p&gt;

&lt;p&gt;Please drop a comment if you've encountered this kind of problem, and tell us what you did that solved it, and also drop a comment if this post has been helpful in one way or the other.&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>docker</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
