<?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>DEV Community: Kristen Kinnear-Ohlmann</title>
    <description>The latest articles on DEV Community by Kristen Kinnear-Ohlmann (@kristenkinnearohlmann).</description>
    <link>https://dev.to/kristenkinnearohlmann</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%2F236415%2Fe8c3af61-e627-4147-a38b-cc735ec2e5d3.png</url>
      <title>DEV Community: Kristen Kinnear-Ohlmann</title>
      <link>https://dev.to/kristenkinnearohlmann</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kristenkinnearohlmann"/>
    <language>en</language>
    <item>
      <title>Using The Python Docstring To Document Functions</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 25 Jul 2022 02:54:07 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/using-the-python-docstring-to-document-functions-49mh</link>
      <guid>https://dev.to/kristenkinnearohlmann/using-the-python-docstring-to-document-functions-49mh</guid>
      <description>&lt;p&gt;I was working through a tutorial on &lt;a href="//realpython.com"&gt;Real Python&lt;/a&gt; and learned an interesting fact that filled a gap I had noted previously.&lt;/p&gt;

&lt;p&gt;A few years ago, I wrote a small Python app to process data from a source to a SQL Server destination. I had been picking up small portions of Python since 2017; while I had enough knowledge to create a working solution, there were many things I know I would have liked to refactor or do more efficiently. One such item was the desire to provide a description for the functions I was abstracting out for the app.&lt;/p&gt;

&lt;p&gt;In the Real Python tutorial, the teacher was discussing &lt;a href="https://peps.python.org/pep-0257/" rel="noopener noreferrer"&gt;docstrings&lt;/a&gt;, a string literal. When it occurs as the first statement in a function, it performs as a special attribute and displays an explanation of the function. The best practice is that it should not be a repeat of the function signature, since that will be displayed already, but a brief explanation of purpose of the function.&lt;/p&gt;

&lt;p&gt;Here is an example of a function without a docstring - only the function signature, if provided, is displayed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;function1&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hi there&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Fbed6127bf9c8874e27a4ee8459056948%2F23313%2Ffunction-no-docstring.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Fbed6127bf9c8874e27a4ee8459056948%2F23313%2Ffunction-no-docstring.jpg" alt="function with no docstring"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is an example of function with a docstring - the contextual help displays the text from the docstring as well as the function signature, if any:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;function2&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Returns a greeting in Portuguese with no variable&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Ola, prazer em conhecer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F3760f58d277aefdb4c5b1cac6e31ad23%2F8e1fc%2Ffunction-with-docstring.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F3760f58d277aefdb4c5b1cac6e31ad23%2F8e1fc%2Ffunction-with-docstring.jpg" alt="function with docstring"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This clears up mysteries in your code, whether all your functions reside in the same file or not. You can quickly recall why you abstracted away the code and how you intended to use it. This functionality can and should be used for methods that are members of a class so developers using your code understand the purpose of the method. All of the same best practices will apply.&lt;/p&gt;

&lt;p&gt;When I have an opportunity to refactor my data processing Python app, I will take advantage of docstrings to help me and other contributing developers quickly understand what each function is doing.&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Favorite String Literals</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 11 Jul 2022 03:09:13 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/favorite-string-literals-2k64</link>
      <guid>https://dev.to/kristenkinnearohlmann/favorite-string-literals-2k64</guid>
      <description>&lt;p&gt;I was recently listening to a JavaScript tutorial on 2x speed when I caught something that caused me to slow down and rewind. The presenter was talking about strings, concatenation, and ES6 string literals. The statement that caught my attention I summarized as "Go ahead and start with template literals first so you don't need to change to backticks later when you need to use a variable".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript&lt;/strong&gt;&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="c1"&gt;// instead of concatenation&lt;/span&gt;
&lt;span class="c1"&gt;// start with a template literal&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numberOfCats&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`I have &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;numberOfCats&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; cats.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Now I have &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;numberOfCats&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; cats.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This struck me as very sensible! There are many advantages to using a string literal instead of a basic statement or simple concatenation and you would save yourself time in refactoring code if you were already using them. They are more readable than other ways of formatting strings; they look like normal sentences and allow you to more easily identify portions to change or update.&lt;/p&gt;

&lt;p&gt;I realized I could apply this kind of strategy to some of the other languages I know as well:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# instead of concatenation
# use an 'f' string in Python 3 right away
&lt;/span&gt;&lt;span class="n"&gt;number_of_cats&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"I have &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;number_of_cats&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; cats"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&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="c1"&gt;// instead of String.Format() (ex. Console.WriteLine("Hello {0}", "world"))&lt;/span&gt;
&lt;span class="c1"&gt;// use string interpolation&lt;/span&gt;
&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;numberOfCats&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"I have &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;numberOfCats&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt; cats."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using these techniques right away in your code, you save time and effort and increase the accuracy of your code when changes occur.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals"&gt;Template literals (template strings)&lt;/a&gt;: MDN&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://realpython.com/python-f-strings/#f-strings-a-new-and-improved-way-to-format-strings-in-python"&gt;f-Strings: A New and Improved Way to Format Strings in Python&lt;/a&gt;: Real Python&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated"&gt;$ - string interpolation (C# reference)&lt;/a&gt;: Microsoft Docs&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Implementing A Dark and Light Mode Toggle</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 04 Jul 2022 01:58:15 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/implementing-a-dark-and-light-mode-toggle-2225</link>
      <guid>https://dev.to/kristenkinnearohlmann/implementing-a-dark-and-light-mode-toggle-2225</guid>
      <description>&lt;p&gt;I was surprised to see that, with my busy June schedule, a full month has passed since my last blog! I have worked on a couple of projects, both personal and professional, in that timeframe that I can write about in the near future.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing The Next Visual ITU Alphabet Enhancement
&lt;/h2&gt;

&lt;p&gt;An enhancement I wanted to make to the &lt;a href="https://visual-itu.netlify.app/"&gt;Visual ITU Alphabet&lt;/a&gt; site was to add a light and dark mode toggle. This has become a very common feature on sites, and I wanted to be able to swap to a less-intense version of colors when my eyes were tired.&lt;/p&gt;

&lt;p&gt;Rather than beginning from zero, I did a quick Google search for example CSS toggles. I found the article &lt;a href="https://alvarotrigo.com/blog/toggle-switch-css/"&gt;20 Best Toggle Switches [Pure CSS Examples]&lt;/a&gt; and liked the very first example, &lt;a href="https://codepen.io/alvarotrigo/pen/zYPydpB"&gt;Dark Mode Toggle Switch&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing The Example Toggle And Adjusting To Fit New Styles
&lt;/h2&gt;

&lt;p&gt;Part of my process is to retype any code I am working with to give my fingers a chance to understand what the code is doing. After reconfiguring the page header to add a space for the toggle to be placed, I performed an initial implementation of the code exactly as the toggle appeared in the example.&lt;/p&gt;

&lt;p&gt;There were a couple of items I identified for completion on this MVP that differed from the example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I wanted the toggle to start in light mode, instead of dark mode as displayed in the example&lt;/li&gt;
&lt;li&gt;I wanted to make the toggle a smaller, single size so I could use it in both smaller and larger displays without needing to resize&lt;/li&gt;
&lt;li&gt;I wanted to add JavaScript to toggle the changes to the site&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was a good opportunity to work on my front-end skills!&lt;/p&gt;

&lt;p&gt;The easiest part was to add some CSS variables to hold the various colors I planned to work with. This allows me to change my color scheme quite easily in the future between light and dark modes. I stuck closer to the default blue and purple colors for links to assist the user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--lightPrimary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#d8dbe0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--lightUnvisitedLink&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#0000ee&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--lightVisitedLink&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#551a8b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--darkPrimary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#28292c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--darkUnvisitedLink&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#0cadff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--darkVisitedLink&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#dcd0ff&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;After choosing a width for my toggle, I thought it would be a simple matter of calculation to get to the values I needed. I tried a lot of math, without a lot of success, before I decided to perform the changes by "eyeballing" what the two phases of the toggle looked like.&lt;/p&gt;

&lt;p&gt;Part of the challenge was changing the toggle from light mode =&amp;gt; dark mode to dark mode =&amp;gt; light mode. Here are the phases of the original design:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nu_sKYfA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/caec55d749799e5605796c3cd541fd45/a805e/toggle-orig-dark-light.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nu_sKYfA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/caec55d749799e5605796c3cd541fd45/a805e/toggle-orig-dark-light.png" alt="original dark and light mode" width="572" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Part of the challenge was resetting the toggle to show light mode first, represented by a round sun-like shape that I realized was simply a shape with a border-radius set. The dark mode shape was the light-mode shape with a box shadow added to it to cut out a crescent. I tried some mirror-image calculations in the Chrome developer tools so I could easily reason and see what the changes looked like. After trial and error, I was able to reverse the modes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Du6d_IYr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/4c259aa65921871f23f4848ecce41e5a/f69fa/toggle-rev-dark-light.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Du6d_IYr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/4c259aa65921871f23f4848ecce41e5a/f69fa/toggle-rev-dark-light.png" alt="revised dark and light mode" width="159" height="52"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To implement the mode color changes, I was able to add some CSS classes I could toggle in my JavaScript function but I wasn't sure how to tackle the body color change. I took the following actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add the primary dark and light colors to the &lt;code&gt;index.js file&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;colorLight&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#fff&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;colorDark&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#3d3d3d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add a function to listen for a click event that inspected the checkbox that was part of the example code
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;modeToggle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;modeToggle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;setElementStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;colorDark&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;colorLight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="nx"&gt;setElementStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;letterInputEntry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;colorDark&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;colorLight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementsByTagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dark-link&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;light-link&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;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;setElementStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;colorLight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;colorDark&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="nx"&gt;setElementStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;letterInputEntry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;colorLight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;colorDark&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementsByTagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;light-link&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dark-link&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;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add &lt;code&gt;setElementStyle&lt;/code&gt; function that I located on another resource to abstract setting a style on an element that is used by the event listener above
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;setElementStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;styles&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;After implementing these changes, I was able to toggle between light and dark modes, with each render displaying properly after each change:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---eAsaIhj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/a80dd49bd967523939df2a68561958cb/98c96/light-mode.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---eAsaIhj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/a80dd49bd967523939df2a68561958cb/98c96/light-mode.jpg" alt="MVP light mode" width="880" height="287"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Oetmisun--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/75be1df989f00d005eb7675a66e1e897/985dc/dark-mode.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Oetmisun--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/75be1df989f00d005eb7675a66e1e897/985dc/dark-mode.jpg" alt="MVP dark mode" width="880" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary And Future Enhancements
&lt;/h2&gt;

&lt;p&gt;The resulting toggle and functionality works well. There are some additional changes I would like to implement:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Determine how I can change body color together with the other CSS changes so I don't need to maintain variables in two files&lt;/li&gt;
&lt;li&gt;Determine how to add additional color schemes&lt;/li&gt;
&lt;li&gt;Determine how to adjust the associated images as well as the text color&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The files that were updated for these changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/kristenkinnearohlmann/itu-alpha/blob/main/assets/styles.css"&gt;assets/styles.css&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/kristenkinnearohlmann/itu-alpha/blob/main/src/index.js"&gt;src/index.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/kristenkinnearohlmann/itu-alpha/blob/main/index.html"&gt;index.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was good practice working with CSS and front-end styling. The identified enhancements will continue that practice and give me an opportunity to refactor the code further.&lt;/p&gt;

</description>
      <category>css</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Using Input Element as Display</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 06 Jun 2022 03:18:08 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/using-input-element-as-display-2ob7</link>
      <guid>https://dev.to/kristenkinnearohlmann/using-input-element-as-display-2ob7</guid>
      <description>&lt;p&gt;This week I picked a project back up that I set aside - the visual ITU alphabet for ham radio operators. Hams may need to spell out words and the ITU alphabet defines a regular English "code" word for each letter to ensure the letter is understood over the air very clearly. I had had a difficult time in the past memorizing the proper words. I know that tying a visual to a concept can assist with memory, so I created &lt;a href="https://visual-itu.netlify.app/"&gt;Visual ITU Alphabet&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I was returning back through projects to add &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing"&gt;&lt;code&gt;box-sizing&lt;/code&gt;&lt;/a&gt; to manage how the content fit on the page, and I recalled that I had to not yet resolved the slight shift when the display letter was clicked and changed to an input. I wanted to make the transition as smooth as possible between the display state and the input state.&lt;/p&gt;

&lt;p&gt;The original layout of the page contained a block element to display the current letter, and a hidden input that was invoked when the block element was clicked:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"display-frame"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"display-letter"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"background-color: blue"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"hidden change-letter"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"change-letter"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt;
      &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"change-letter"&lt;/span&gt;
      &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"change-letter-input"&lt;/span&gt;
      &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;
      &lt;span class="na"&gt;maxlength=&lt;/span&gt;&lt;span class="s"&gt;"1"&lt;/span&gt;
      &lt;span class="na"&gt;pattern=&lt;/span&gt;&lt;span class="s"&gt;"[A-Za-z]{1}"&lt;/span&gt;
    &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At some point after I released Visual ITU Alphabet, I created &lt;a href="https://minutes-only.netlify.app/"&gt;Minutes Only Timer&lt;/a&gt; for my husband. For that project, I resolved the issues of having an input that accepted numbers for time by using an input element for both the display and the input. I realized I could take this same approach with Visual ITU Alphabet.&lt;/p&gt;

&lt;p&gt;The simplest step was to remove the former display block and retain only the input; I revised the block elements and classes to handle the styling for alignment and font:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"display-frame"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"letter-entry"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt;
      &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"letter-input"&lt;/span&gt;
      &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"letter-input-entry"&lt;/span&gt;
      &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;
      &lt;span class="na"&gt;maxlength=&lt;/span&gt;&lt;span class="s"&gt;"1"&lt;/span&gt;
      &lt;span class="na"&gt;pattern=&lt;/span&gt;&lt;span class="s"&gt;"[A-Za-z]{1}"&lt;/span&gt;
    &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I styled the classes to ensure the input element, whether in "display mode" or "entry mode", would have a font and size that correlated to the other elements on the page, as well as maintain a consistent margin between the input and the letter image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.display-frame&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;flex-flow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt; &lt;span class="nb"&gt;nowrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;75%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.letter-entry&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;align-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.letter-input&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"Times New Roman"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Times&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&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;These changes allowed me to simplify the logic that handled the letter processing itself, as well as ensure the focus is removed from the input so the "display mode" looks like normal text:&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;displayAlpha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;currentLetter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;AlphaLetter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;alpha&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;alphaPosition&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

  &lt;span class="c1"&gt;// after retrieving the letter value, invoke the blur() function to deselect the input&lt;/span&gt;
  &lt;span class="nx"&gt;letterInputEntry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;currentLetter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;letter&lt;/span&gt;
  &lt;span class="nx"&gt;letterInputEntry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="nx"&gt;displayLetterImg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;currentLetter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;renderLetterImg&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="nx"&gt;phoneticWord&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;currentLetter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;phoneticWord&lt;/span&gt;
  &lt;span class="nx"&gt;pronunciation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;currentLetter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stressPronounce&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;updateDisplayLetter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;newLetter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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="nx"&gt;toUpperCase&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;newLetterPosition&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;alpha&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newLetter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;alphaPosition&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newLetterPosition&lt;/span&gt;

  &lt;span class="nx"&gt;displayAlpha&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// clear the value from the input&lt;/span&gt;
&lt;span class="nx"&gt;letterInputEntry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;letterInputEntry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// update the letter if one was entered and the user clicked out of the field&lt;/span&gt;
&lt;span class="nx"&gt;letterInputEntry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blur&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;letterInputEntry&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="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;letterInputEntry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;currentLetter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;letter&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;updateDisplayLetter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// update the letter if one was entered and the user pressed enter&lt;/span&gt;
&lt;span class="nx"&gt;letterInputEntry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;keyup&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;keyPressed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;keyPressed&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Enter&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;letterInputEntry&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="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;letterInputEntry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;currentLetter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;letter&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;updateDisplayLetter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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;It's quite delightful to be able to view the site on my mobile phone. Clicking and changing the letter no longer shifts content on the page, and the current letter is restored if a user clears the input, fails to put in a new letter and exits the input. While there are still other opportunities for refactoring this code, this functionality enhancement makes the app even easier to use while I review other changes.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>css</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Basic PostgreSQL on the Command Line</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 23 May 2022 02:47:14 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/basic-postgresql-on-the-command-line-a17</link>
      <guid>https://dev.to/kristenkinnearohlmann/basic-postgresql-on-the-command-line-a17</guid>
      <description>&lt;p&gt;I started working through &lt;a href="https://www.freecodecamp.org/" rel="noopener noreferrer"&gt;freeCodeCamp's&lt;/a&gt; beta curriculum for &lt;a href="https://www.freecodecamp.org/learn/relational-database/" rel="noopener noreferrer"&gt;Relational Database&lt;/a&gt;. I like to have a contrasting educational opportunity when I need a mental break; solutions to data structure and algorithm problems and other coding questions usually come to me when I'm studying a different topic.&lt;/p&gt;

&lt;p&gt;Since databases are my original jam, I thought it would be profitable to work on my command line-level skills so I can gain strength with other types of databases. The first lessons introduce you to working with PostgreSQL to learn syntax. Although I'm very familiar with SQL itself, it had been some time since I had worked with Postgres on the command line. Part of the &lt;a href="https://flatironschool.com/" rel="noopener noreferrer"&gt;Flatiron School&lt;/a&gt; curriculum had students install Postgres (for me, on my WSL install) but we used SQLite for projects so my knowledge of accessing and using Postgres had gotten fuzzy.&lt;/p&gt;

&lt;p&gt;After spending a few days on the &lt;a href="https://codeally.io/" rel="noopener noreferrer"&gt;CodeAlly&lt;/a&gt; platform that is included in freeCodeCamp's lessons, I decided to try looking back into my local install and get a set of basic instructions together. This will help when I return to my Flatiron projects to convert them to Postgres and deploy them to publicly available servers. For more information on installing Postgres, see &lt;a href="https://www.postgresql.org/" rel="noopener noreferrer"&gt;https://www.postgresql.org/&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working with &lt;code&gt;psql&lt;/code&gt; on WSL
&lt;/h2&gt;

&lt;p&gt;I knew I had Postgres installed so the first thing I tried was to invoke it. I received an error message.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F7a03fa4dd03c2d2fe6113e2067e19373%2Ff6dd8%2Fpsql-01-check.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F7a03fa4dd03c2d2fe6113e2067e19373%2Ff6dd8%2Fpsql-01-check.jpg" alt="Check psl"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I vaguely recalled that the service is generally stopped so I tracked down the command to get it started.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F527c450689c324011105365bfe2ce214%2F1c72d%2Fpsql-02-start.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F527c450689c324011105365bfe2ce214%2F1c72d%2Fpsql-02-start.jpg" alt="Start postgres service"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I was now able to access &lt;code&gt;psql&lt;/code&gt;. I had created an account for myself as part of my Flatiron studies so my account name appears as the prompt.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Ff86f739f1e93534aad3320c907e235aa%2Fe49d1%2Fpsql-03-open.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Ff86f739f1e93534aad3320c907e235aa%2Fe49d1%2Fpsql-03-open.jpg" alt="Open postgres"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I didn't know what databases had been created, so I listed them with &lt;code&gt;\l&lt;/code&gt;. There were a lot more than I recalled!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Fa89d7844c6673880deb7d42bb67db527%2F7b510%2Fpsql-04-list.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Fa89d7844c6673880deb7d42bb67db527%2F7b510%2Fpsql-04-list.jpg" alt="List databases"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I connected to one of the databases I recognized from the setup lesson for Flatiron.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F1ef4aa7801c4ca082586256c88771db8%2F82d6d%2Fpsql-05-connect.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F1ef4aa7801c4ca082586256c88771db8%2F82d6d%2Fpsql-05-connect.jpg" alt="Connect to database"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I reviewed the objects that were included in this database. The lesson must have been using a blog as the object to model, since one of the objects was a &lt;code&gt;posts&lt;/code&gt; table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Fc6b62b0d367a3906760c0a26dbe1f90e%2Fa77ef%2Fpsql-06-relations.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Fc6b62b0d367a3906760c0a26dbe1f90e%2Fa77ef%2Fpsql-06-relations.jpg" alt="Review relations"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I further reviewed what the sample lesson asked us to create as fields in the &lt;code&gt;posts&lt;/code&gt; table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Fb73576a4f03a24ab2006ead165faf8e9%2F9888a%2Fpsql-07-table.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Fb73576a4f03a24ab2006ead165faf8e9%2F9888a%2Fpsql-07-table.jpg" alt="Review fields"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I connected to a few other relations but found they were empty, so I went ahead and quit Postgres.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Fce4e7d8536366f76eb80865db3af16bb%2Fe52b6%2Fpsql-08-quit.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Fce4e7d8536366f76eb80865db3af16bb%2Fe52b6%2Fpsql-08-quit.jpg" alt="Quit Postgres"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I also stopped the Postgres service until I needed it again.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F284f274539a3f19096081efa0ae2be34%2Fd52bd%2Fpsql-09-stop.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F284f274539a3f19096081efa0ae2be34%2Fd52bd%2Fpsql-09-stop.jpg" alt="Stop Postgres service"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic commands for &lt;code&gt;psql&lt;/code&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Check if &lt;code&gt;psql&lt;/code&gt; is accessible
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;psql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Start Postgres service
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo service postgres start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;List available databases
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\l
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Connect to a specific database to work within it
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\c &amp;lt;database_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Review relations in the database
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Review details of a specific relation
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\d &amp;lt;relation_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Quit Postgres
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\q
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Stop Postgres service
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo service postgres stop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>postgres</category>
      <category>tutorial</category>
      <category>linux</category>
    </item>
    <item>
      <title>Practice LeetCode Problem - Implement strStr()</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 09 May 2022 02:41:29 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/practice-leetcode-problem-implement-strstr-279j</link>
      <guid>https://dev.to/kristenkinnearohlmann/practice-leetcode-problem-implement-strstr-279j</guid>
      <description>&lt;p&gt;I have been diligently working on data structure and algorithm problems from various sources. Today I worked on the &lt;a href="https://leetcode.com/problems/implement-strstr/"&gt;&lt;code&gt;Implement strStr()&lt;/code&gt;&lt;/a&gt; problem using JavaScript. This problem is part of the Easy set that LeetCode maintains.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Setup
&lt;/h2&gt;

&lt;p&gt;The basic premise of the problem is to find a shorter string (the "needle") within a longer string (the "haystack"). All LeetCode problems expect that you will solve the problem both correctly and efficiently.&lt;/p&gt;

&lt;p&gt;The instructions gave some help with expectations and edge cases. It's always nice when you can get some "freebie" information, and it helps me learn to think about edge cases. With the following information, I could take a few actions right away:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Return 0 if no needle is given&lt;/strong&gt;: I checked the value of &lt;code&gt;needle&lt;/code&gt; at the top of the function I wrote and added an immediate return for a falsey value&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Return -1 if the needle is not found in the haystack&lt;/strong&gt;: I set my &lt;code&gt;returnVal&lt;/code&gt; variable to -1 so that I could simply change the value if the &lt;code&gt;needle&lt;/code&gt; was found in the &lt;code&gt;haystack&lt;/code&gt; during processing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I confirmed I could check the length of the &lt;code&gt;needle&lt;/code&gt; without converting it to an array, and I stored that value as &lt;code&gt;needleLength&lt;/code&gt; so I could access it multiple times without invoking a processing cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  Loop Processing
&lt;/h2&gt;

&lt;p&gt;I wanted to use a loop to perform the processing, and determined that I could use a &lt;code&gt;do&lt;/code&gt; loop. The principal problem I wanted to solve was how to know when to end the loop. I tried a couple of iterations but I caused my &lt;a href="//replit.com"&gt;Replit.com&lt;/a&gt; repl to go into an infinite loop.&lt;/p&gt;

&lt;p&gt;I decided to fall back to a simple &lt;code&gt;for&lt;/code&gt; loop to try out my assumptions. I found that my use of the &lt;code&gt;slice&lt;/code&gt; method needed to include &lt;code&gt;needleLength&lt;/code&gt; + the current index position (represented by the classic &lt;code&gt;i&lt;/code&gt;) to process the &lt;code&gt;haystack&lt;/code&gt; substring properly. When I returned to my selected &lt;code&gt;do&lt;/code&gt; loop, I realized I needed to use an &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; condition in my &lt;code&gt;while&lt;/code&gt; check for checking both the length of &lt;code&gt;haystack&lt;/code&gt; left as well as the ability to short-circuit the loop if the &lt;code&gt;returnVal&lt;/code&gt; was set to something other than the default -1.&lt;/p&gt;

&lt;p&gt;I tried the test cases that were outlined in the problem, removed my extra code, and reviewed my function to see if I could make it more efficient before submission. Once tested and submitted, I found that I had failed a test case, an edge case I had not checked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Refactor
&lt;/h2&gt;

&lt;p&gt;The edge case returned in the failed submission was to correctly return the start index if the &lt;code&gt;needle&lt;/code&gt; was found at the end of the string. It was a little embarrassing - the &lt;code&gt;haystack&lt;/code&gt; was a simple &lt;code&gt;'abc'&lt;/code&gt; and the &lt;code&gt;needle&lt;/code&gt; was &lt;code&gt;'c'&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;I added the failed test case to my repl to help refactor the code. I determined that my &lt;code&gt;while&lt;/code&gt; check needed to check that the &lt;code&gt;needleLength + i&lt;/code&gt; value was &lt;code&gt;&amp;lt;=&lt;/code&gt; the length of &lt;code&gt;haystack&lt;/code&gt;; I previously was checking for just &lt;code&gt;&amp;lt;&lt;/code&gt;. I re-tested all of my test cases and re-submitted the solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Outcome
&lt;/h2&gt;

&lt;p&gt;The refactored solution was accepted with a runtime of 63 ms (faster than 87.45% of other submissions) and memory usage of 42.4 MB (less than 45.78% of other solutions). I checked the Discussion tab, filtered by JavaScript solutions, to see what other information I could gather. I found a few shorter solutions and one checking an edge case where &lt;code&gt;needle&lt;/code&gt; already matched &lt;code&gt;haystack&lt;/code&gt; that I will return to study.&lt;/p&gt;

&lt;p&gt;With continued practice, I have noted that I am able to come up with a solution for a problem faster than I was able to previously, and can more easily resolve failed test cases. I still need to learn and practice identifying edge cases which will aid me in being able to craft a correct and efficient solution in a shorter timeframe. My work repl is located at &lt;a href="https://replit.com/@kristenkinnearo/LeetCode-strStr#index.js"&gt;https://replit.com/@kristenkinnearo/LeetCode-strStr#index.js&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>algorithms</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Data Structure and Algorithm Problem Solving Toolbox</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 25 Apr 2022 03:30:44 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/data-structure-and-algorithm-problem-solving-toolbox-241b</link>
      <guid>https://dev.to/kristenkinnearohlmann/data-structure-and-algorithm-problem-solving-toolbox-241b</guid>
      <description>&lt;p&gt;I have been working on solving data structure and algorithm problems for about 8 months. It's interesting to recall how lost I was when I first started - it was like being in school and first learning word problems for math! I now have some tools I refer to that have helped me become stronger and faster with my solutions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fully Read the Question/Problem
&lt;/h2&gt;

&lt;p&gt;I internalized this piece of advice after watching a &lt;a href="https://www.youtube.com/user/beccibri/videos"&gt;Bytes of Bree video&lt;/a&gt;. She was describing a coding challenge she was working on in which the person giving the challenge asked her to read the question and determine what it was asking her. She said that she had been getting too complex with her answer, and one of the accepted solutions was quite simple. She found it only after focusing on what the challenge was asking her specifically to do.&lt;/p&gt;

&lt;p&gt;I often rush through things I don't know well, as if getting through the exercise with my eyes closed will allow it to magically solve itself. I have been working on slowing down and really understanding the information that has been given to me. This is easier on sites and in situations where there is no timer, but I have found value in not worrying about timers and taking the time I need.&lt;/p&gt;

&lt;p&gt;I was able to apply this recently to a problem involving finding the gaps in binary numbers. I remember trying to tackle this problem a couple months ago and feeling pretty frustrated. When I picked it up this time and read the question, I realized the input value was an integer and I would need to convert it to binary; I had been assuming a binary number was being passed in the test suite.&lt;/p&gt;

&lt;p&gt;One other key point to this item is that the problem will usually tell you what is most important - efficiency or correctness. I like correctness problems, because you can focus on accuracy and not worry about the time complexity. Now that I have some experience with problems, I know efficiency means I should be looking for a solution that performs the fewest possible passes through the input.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check All Inputs and Outputs
&lt;/h2&gt;

&lt;p&gt;Although I now read through problems completely and understand what's being asked, I needed to also check the inputs and outputs that the problem was expecting.&lt;/p&gt;

&lt;p&gt;I recently worked through a problem that involved rotating elements of an array. I read through the problem, started the solution in my head (&lt;em&gt;I'll need to splice out a portion of the array and unshift the array to add to the beginning&lt;/em&gt;), quickly implemented my solution, and started the test suite on the site I was using. I only received 87%! What did I do wrong?&lt;/p&gt;

&lt;p&gt;I examined the failed test case example and realized that I had not checked what values the rotation count could take in. After examining the inputs for the function, I saw that it could be larger than length of the array. I hadn't accounted for that, and there was a straightforward way to do so. After implementing a couple of revisions of my solution, I was able to score 100%.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Your Search Tools
&lt;/h2&gt;

&lt;p&gt;When you are practicing, go ahead and Google the things you can't quite remember. At this point, you don't need to have everything at your fingertips, because you're working on knowing HOW to solve the problems first.&lt;/p&gt;

&lt;p&gt;In the problem I discussed above, I knew I could get a remainder of the number of move positions for the array elements. My poor brain decided the way to do this was to divide one number by the other, then apply the &lt;code&gt;floor&lt;/code&gt; function I confirmed via Google to get back to an integer. Makes sense, right?&lt;/p&gt;

&lt;p&gt;I tested the solution and received 75%, which was lower than my first score. I studied the failed example test case, and did another Google search. If I had done a little additional searching the first time, my memory would have served up the &lt;code&gt;modulo&lt;/code&gt; function, which is a much more accurate remainder for the operation I was doing. I also Googled the best function to convert an integer to a binary from the earlier problem I worked on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Take a Break
&lt;/h2&gt;

&lt;p&gt;Many of us that study software engineering are perfectionists, problem-solvers, focused or all 3. It's easy for us to get stuck on something; we just KNOW we're going to figure out this problem, we just need to keep hammering away at it!&lt;/p&gt;

&lt;p&gt;I've found the greatest success is in taking a break. Classic Pomodoro method states that focus work should be 25 minutes in length. I've seen advice that after 20 minutes of working on a problem, take a break or review solutions on the site you are using, if they are available. There are also people that are in a "zen flow state" and take a break when they lose focus.&lt;/p&gt;

&lt;p&gt;I have used all of these methods with good results. The only time I don't have good results is when I try to keep pushing through to prove a point. Always take those breaks!&lt;/p&gt;

&lt;h2&gt;
  
  
  Summarize Your Work
&lt;/h2&gt;

&lt;p&gt;After I solve problems now, I document them in my own words. This helps me review and understand the steps I took and to see what patterns start to emerge from those solutions. I include where I got hung up, any interim scores I received for my submitted solutions, and the time it took for me to work on the problem, in the event I have a timed set of problems to work on.&lt;/p&gt;

&lt;p&gt;I use &lt;a href="https://replit.com"&gt;Replit&lt;/a&gt; to work on my problems before adding them back to the site the problem is on. This helps me focus better because I'm already totally familiar with the tools and how to use them. It also allows me to save my working copies, add comments and reference them later. I include the link to the specific &lt;code&gt;repl&lt;/code&gt; in my summary document for the problem. You may also choose to set up a repo with a test suite for this same purpose. Either way you have a source of code from which to summarize your solution and conclusions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seek Resources
&lt;/h2&gt;

&lt;p&gt;More than just looking for the best function or some insight, seeking resources means finding people and videos that can help deepen your understanding.&lt;/p&gt;

&lt;p&gt;I am a member of some Slack workspaces for developers where people discuss data structure and algorithm problems. I've talked with colleagues about what they know. I've read solutions on &lt;a href="https://leetcode.com/"&gt;LeetCode&lt;/a&gt;. I've watched other developers' videos.&lt;/p&gt;

&lt;p&gt;All of these resources give me a different perspective on how to solve problems as well as techniques and information I am not yet familiar with. I write blogs about this information so that I can be a resource to others as well; finding a resource that "speaks your language" allows you to make great leaps in your understanding and ability. I encourage everyone to be the resource they can be for this reason!&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't Give Up
&lt;/h2&gt;

&lt;p&gt;This isn't a counter-statement to the &lt;strong&gt;Take a Break&lt;/strong&gt; item above, it is a complementary item. Sometimes these problems can seem insurmountable and that you may never be able to solve them. You may even set them aside for some period of time. I encourage you, and myself, to pick these problems up again in another session. I know these problems are valuable for learning patterns, efficiency and problem-solving, and I don't want to leave any knowledge behind.&lt;/p&gt;

&lt;p&gt;If there is a problem I can't solve in 1 session, I will submit what I do have, take note of any feedback and save it in my &lt;code&gt;repl&lt;/code&gt; for the problem. I can then pick up another problem-solving session with my previous input. I find my brain will be working on new approaches while I sleep, or go running, or take a shower, so having a good stopping point to pick up from allows me to keep working efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I am early in my journey of mastering data structures and algorithms. I appreciate these tools I have defined to assist me, and I look forward to identifying more as I continue my learning.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Styling the SelectControl from Formik with Chakra UI</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 18 Apr 2022 02:10:44 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/styling-the-selectcontrol-from-formik-with-chakra-ui-2345</link>
      <guid>https://dev.to/kristenkinnearohlmann/styling-the-selectcontrol-from-formik-with-chakra-ui-2345</guid>
      <description>&lt;p&gt;I resolved an interesting issue while continuing the build on my registration form for the &lt;a href="https://breeze-lakes-point-2.vercel.app/signin" rel="noopener noreferrer"&gt;Breeze Lakes Point&lt;/a&gt; project using Next.js. I really struggled to find the proper way to style the Formik Chakra UI &lt;code&gt;SelectControl&lt;/code&gt; component so that it matched the other controls. I wanted to have drop-down lists styled with the same grey background and white text that was the default for the form.&lt;/p&gt;

&lt;p&gt;The default theme style for the &lt;code&gt;SelectControl&lt;/code&gt; was to display the drop-down items with a white background that blended with my text color, which is set to white.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F9b702efe74e134f8b568cecfc53b58b1%2Fcd1d6%2Fimg1-defaultstyle-formikchakraui.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F9b702efe74e134f8b568cecfc53b58b1%2Fcd1d6%2Fimg1-defaultstyle-formikchakraui.png" alt="default style SelectControl formik-chakra-ui"&gt;&lt;/a&gt;&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;SelectControl&lt;/span&gt;
    &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;pronoun&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;pronoun&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Pronoun&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="nx"&gt;marginLeft&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;10px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;nbsp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;she&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;her&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;he&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;him&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;they&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;them&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/SelectControl&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I Googled for a solution but wasn't finding anything that helped me determine how to reset the background color of the drop-down items on the &lt;code&gt;SelectControl&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I was able to style a conventional &lt;code&gt;select&lt;/code&gt; control with classes defined in my &lt;code&gt;global.css&lt;/code&gt; so that the display matched the other form controls.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F83d9fe9e5edbccf85f79b90e9f2b94e4%2Faec65%2Fimg2-conventional-select.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F83d9fe9e5edbccf85f79b90e9f2b94e4%2Faec65%2Fimg2-conventional-select.png" alt="conventional select control"&gt;&lt;/a&gt;&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;select&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bgtransparent form-element&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bgtransparent-child&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;nbsp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bgtransparent-child&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;she&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;her&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bgtransparent-child&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;he&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;him&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bgtransparent-child&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;they&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;them&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/select&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The issue with this solution was that I wasn't able to leverage the Formik and Yup conventions to populate the control with values, validate input values, or gather the selected values for use in form submission. I could certainly have written some additional functions to handle those actions but I wanted to be able to manage all form inputs in the same way. Using the &lt;code&gt;SelectControl&lt;/code&gt; included with &lt;code&gt;formik-chakra-ui&lt;/code&gt; was the way to accomplish those goals, but the configuration that worked for a conventional &lt;code&gt;select&lt;/code&gt; control did not work for a &lt;code&gt;formik-chakra-ui&lt;/code&gt; &lt;code&gt;SelectControl&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I spent some time simply hovering over pieces of my code in VS Code to see what the intellisense might suggest for formatting the &lt;code&gt;SelectControl&lt;/code&gt;. I tried a few options but was drawn back to the option to use HTML Attributes.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Ff0afd31e12381120bdb6e6445f17105d%2Fe9d87%2Fimg3-jsx-html-attrs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2Ff0afd31e12381120bdb6e6445f17105d%2Fe9d87%2Fimg3-jsx-html-attrs.png" alt="VS Code intellisense"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I recalled in my searches and other code examples that the use of the double &lt;code&gt;{{}}&lt;/code&gt; allowed execution for code like additional formatting. I added &lt;code&gt;style={{ backgroundColor: "gray" }}&lt;/code&gt; to each option for the &lt;code&gt;SelectControl&lt;/code&gt; to blend into the current page color.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;SelectControl&lt;/span&gt;
    &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;pronoun&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;pronoun&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Pronoun&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="nx"&gt;marginLeft&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;10px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gray&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;nbsp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gray&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nx"&gt;she&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;her&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gray&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nx"&gt;he&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;him&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gray&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nx"&gt;they&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;them&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/SelectControl&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code allowed me to style the &lt;code&gt;SelectControl&lt;/code&gt; to match my page style and capture the values for submission to the database.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F05f392f6e8672b5ec68b67ee9fd7900e%2F0acb4%2Fimg4-final-dropdown.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F05f392f6e8672b5ec68b67ee9fd7900e%2F0acb4%2Fimg4-final-dropdown.png" alt="working formik-chakra-ui SelectControl"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F8aca25044a6bed3019d0642db9e84476%2Fe0885%2Fimg5-submitted-data.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkristenkinnearohlmann.dev%2Fstatic%2F8aca25044a6bed3019d0642db9e84476%2Fe0885%2Fimg5-submitted-data.png" alt="submitted data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next refactor of this code is to write a more flexible option for incorporating styles into the individual options.&lt;/p&gt;

&lt;p&gt;I wasn't able to find any other sources that explained how to accomplish the solution. I hope this explanation will be helpful to other developers working with Next.js, Formik, and Chakra UI.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Reset Ubuntu Password on Windows</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 11 Apr 2022 02:37:51 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/reset-ubuntu-password-on-windows-5e4l</link>
      <guid>https://dev.to/kristenkinnearohlmann/reset-ubuntu-password-on-windows-5e4l</guid>
      <description>&lt;p&gt;This week, I wanted to check a Docker command within Docker itself. I have been working with the &lt;code&gt;dockerd&lt;/code&gt; engine on my Windows WSL 2 installation. Although I had been working through the terminal in VS Code, I wanted to try using the Ubuntu shell.&lt;/p&gt;

&lt;p&gt;I found I had 2 versions of Ubuntu installed, each with its own password, and later realized I needed to log into the WSL shell. I researched and located a helpful solution on Stack Exchange that I summarized for use again in the future.&lt;/p&gt;

&lt;h2&gt;
  
  
  Password Change Process
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Using the Ubuntu shell, note the following:

&lt;ul&gt;
&lt;li&gt;The version of Ubuntu you are using (I had a previous install as well as Ubuntu 18.04 in WSL)&lt;/li&gt;
&lt;li&gt;Your username&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Close the Ubuntu shell&lt;/li&gt;
&lt;li&gt;Open PowerShell as &lt;strong&gt;Admin&lt;/strong&gt; and reset the Ubuntu config to log in as &lt;code&gt;root&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;Ubuntu:
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  ubuntu config &lt;span class="nt"&gt;--default-user&lt;/span&gt; root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Ubuntu 18.04:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  ubuntu1804 config &lt;span class="nt"&gt;--default-user&lt;/span&gt; root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Re-open the Ubuntu shell - you will be logged in as &lt;code&gt;root&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Execute the &lt;code&gt;passwd&lt;/code&gt; command and follow the prompts; ensure you secure your new password in a password safe! Do not include angle brackets.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   passwd &amp;lt;username&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Close the Ubuntu shell&lt;/li&gt;
&lt;li&gt;Open PowerShell as &lt;strong&gt;Admin&lt;/strong&gt; and reset the Ubuntu config to log in as your username. Do not include angle brackets.

&lt;ul&gt;
&lt;li&gt;Ubuntu:
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  ubuntu config &lt;span class="nt"&gt;--default-user&lt;/span&gt; &amp;lt;username&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Ubuntu 18.04:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  ubuntu1804 config &lt;span class="nt"&gt;--default-user&lt;/span&gt; &amp;lt;username&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Log into Ubuntu and confirm the new password&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I followed these steps for both versions of Ubuntu, and I was able to reset both passwords. Once I opened the WSL shell, I was able to use my Ubuntu 18.04 credentials to start &lt;code&gt;dockerd&lt;/code&gt; and check the commands I needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://askubuntu.com/questions/772050/reset-the-password-in-ubuntu-linux-bash-in-windows"&gt;Reset the password in Ubuntu/Linux Bash in Windows&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ubuntu</category>
      <category>wsl</category>
      <category>windows</category>
    </item>
    <item>
      <title>Add a Field to a Prisma Model</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 04 Apr 2022 02:48:31 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/add-a-field-to-a-prisma-model-22ja</link>
      <guid>https://dev.to/kristenkinnearohlmann/add-a-field-to-a-prisma-model-22ja</guid>
      <description>&lt;p&gt;My &lt;a href="https://breeze-lakes-point-2.vercel.app/profile"&gt;Breeze Lakes Point&lt;/a&gt; project is in a good working state with my initial User model for logging in and displaying the data from the table. As I was implementing the model, I realized I wanted to capture Middle Name or whether a user didn't have a middle name as part of the sign up process.&lt;/p&gt;

&lt;p&gt;When I was building the User model, I ran into trouble with TypeScript recognizing that my model had changed. My new fields were flagged as errors and the data didn't display. I resolved the issue at the time but couldn't recall exactly all the steps I took. Adding Middle Name was my opportunity to define that process.&lt;/p&gt;

&lt;p&gt;In my project, I am using the &lt;code&gt;npx&lt;/code&gt; package runner to work with &lt;a href="https://www.prisma.io/"&gt;Prisma&lt;/a&gt;. For more information, see the &lt;a href="https://nodejs.dev/learn/the-npx-nodejs-package-runner"&gt;article on nodejs.dev&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I started by adding &lt;code&gt;middleName&lt;/code&gt; and &lt;code&gt;noMiddleName&lt;/code&gt; to my User model. &lt;code&gt;noMiddleName&lt;/code&gt; is a boolean to allow a user to indicate that they truly don't have a middle name, without the need to add inaccurate data to the &lt;code&gt;middleName&lt;/code&gt; field.&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;model&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;id&lt;/span&gt;           &lt;span class="nb"&gt;String&lt;/span&gt;   &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;id&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="nx"&gt;createdAt&lt;/span&gt;    &lt;span class="nx"&gt;DateTime&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;now&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="nx"&gt;updatedAt&lt;/span&gt;    &lt;span class="nx"&gt;DateTime&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;updatedAt&lt;/span&gt;
  &lt;span class="nx"&gt;username&lt;/span&gt;     &lt;span class="nb"&gt;String&lt;/span&gt;   &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;unique&lt;/span&gt;
  &lt;span class="nx"&gt;password&lt;/span&gt;     &lt;span class="nb"&gt;String&lt;/span&gt;
  &lt;span class="nx"&gt;email&lt;/span&gt;        &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;
  &lt;span class="nx"&gt;firstName&lt;/span&gt;    &lt;span class="nb"&gt;String&lt;/span&gt;
  &lt;span class="nx"&gt;middleName&lt;/span&gt;   &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;
  &lt;span class="nx"&gt;lastName&lt;/span&gt;     &lt;span class="nb"&gt;String&lt;/span&gt;
  &lt;span class="nx"&gt;noMiddleName&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;default&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="nx"&gt;role&lt;/span&gt;         &lt;span class="nx"&gt;Role&lt;/span&gt;     &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;User&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;You can choose to run &lt;code&gt;npx prisma db push&lt;/code&gt; to review the changes or &lt;code&gt;npx prisma migrate dev&lt;/code&gt; to create a migration and apply the data. I ran the latter command since I knew the fields were what I wanted in the model. I also ran &lt;code&gt;npx prisma generate&lt;/code&gt; to ensure I had a new client to work with.&lt;/p&gt;

&lt;p&gt;I recalled that around this step previously, my Javascript code was not able to see the changes. There were some TypeScript complaints and some other vague errors; I was not able to update my seed file to incorporate the new fields. During the earlier issue, I had deleted all my terminals but ultimately it seemed the issue was resolved once I closed and re-opened my project in a new VS Code window. This time, I took those actions immediately, as well as re-running &lt;code&gt;npx prisma generate&lt;/code&gt;, and was able to go ahead and start adding the new fields to my seed file. Success!&lt;/p&gt;

&lt;p&gt;I modeled both a &lt;code&gt;noMiddleName&lt;/code&gt; and &lt;code&gt;middleName&lt;/code&gt; value in my seed file.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;upsert&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
    &lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;redacted&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;User&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="dl"&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="s2"&gt;&amp;lt;redacted&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;noMiddleName&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;upsert&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user4@user.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
    &lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user4@user.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;redacted&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;"&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user4@user.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;User&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;middleName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;S&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;With my seed file updated, I ran the following commands to truncate the current database on Heroku and re-seed the data.&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;npx&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt; &lt;span class="nx"&gt;migrate&lt;/span&gt; &lt;span class="nx"&gt;reset&lt;/span&gt;
&lt;span class="nx"&gt;npx&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="nx"&gt;seed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, I opened the model on the database to visualize the changes.&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;npx&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt; &lt;span class="nx"&gt;studio&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Identifying the best process and procedure for adding to existing models, adding new models, and ensuring the changes are available to the main project code has helped speed up my development process. I can now start to build the additional models I need to begin adding features to the base project.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>database</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Basic Setup for Azure Cosmos DB and Example Node App</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 28 Mar 2022 04:08:41 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/basic-setup-for-azure-cosmos-db-and-example-node-app-ff8</link>
      <guid>https://dev.to/kristenkinnearohlmann/basic-setup-for-azure-cosmos-db-and-example-node-app-ff8</guid>
      <description>&lt;p&gt;I have had an opportunity to work on a project that uses &lt;a href="https://azure.microsoft.com/en-us/services/cosmos-db/"&gt;Azure Cosmos DB&lt;/a&gt; with the &lt;a href="https://docs.microsoft.com/en-us/azure/cosmos-db/mongodb/mongodb-introduction"&gt;MongDB API&lt;/a&gt; as the backend database. I wanted to spend a little more time on my own understanding how to perform basic setup and a simple set of CRUD operations from a Node application, as well as construct an easy-to-follow procedure for other developers.&lt;/p&gt;

&lt;p&gt;I have an Azure account that I created to explore Microsoft's capabilities, which I used to write this blog. At the time I created my account, I was not able to use a Gmail account, although this may have changed. If you are interested in following the steps below, I recommend getting your Azure account established first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create and Configure Cosmos DB instance
&lt;/h2&gt;

&lt;p&gt;After logging into Azure, the first step is to navigate to Portal, which contains all of the Azure cloud-based services.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--etPy_xJa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/a333008e3349f88676fbad8032de5934/a0a88/azure-1-welcome.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--etPy_xJa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/a333008e3349f88676fbad8032de5934/a0a88/azure-1-welcome.jpg" alt="Azure Portal" width="880" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Services are pay per use and you'll be asked to provide a credit card even for the free trial. Make a note of when your trial period ends, so you can be aware when charges will start to accrue. As with other clouds, costs for smaller, personal applications will be nominal, but it is worth ensuring you know when the trial period ends to monitor use.&lt;/p&gt;

&lt;p&gt;Locate the Cosmos DB option to start creating the service.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qnvPBJsI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/26caeb11f79ff0afc1182c4bfe85e38d/1a144/azure-2-cosmos-select.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qnvPBJsI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/26caeb11f79ff0afc1182c4bfe85e38d/1a144/azure-2-cosmos-select.jpg" alt="Azure Cosmos DB icon" width="730" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If this is the first instance to be created, the option to create a new account will be the main content on the page.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z2Xk9h4R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/7e39a8ba646fa90105e7fb3cf4661a2a/be464/azure-3-create-cosmos-acct.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z2Xk9h4R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/7e39a8ba646fa90105e7fb3cf4661a2a/be464/azure-3-create-cosmos-acct.jpg" alt="Azure Create new Cosmos DB account" width="880" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first part of configuration is selecting a connection API. Microsoft encourages you to use the Core (SQL) option, which correlates to familiar SQL syntax for creating and using resources; there are SDKs for .NET, Javascript, Python and Java. There are a number of other APIs available, each with a description of their capabilities. The project I was modeling used the document database MongoDB API, so I selected &lt;strong&gt;Azure Cosmos DB API for MongoDB&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kjBJRhYi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/99abace9847a3aa71f8a86da1690622e/501da/azure-4-api-choice.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kjBJRhYi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/99abace9847a3aa71f8a86da1690622e/501da/azure-4-api-choice.jpg" alt="Azure choose database connection API" width="880" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second part of configuration is the project details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resource Group&lt;/strong&gt;: Likely you will need to create a new Resource Group to have a selection. Resource Groups are similar to folders, used to organize and manage resources. I named mine &lt;strong&gt;SampleMongo&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Account Name&lt;/strong&gt;: This is a unique account name; requirements are that it must be lower case and hyphen is the only character allowed other than letters. I named mine &lt;strong&gt;samplemongoacct&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capacity mode&lt;/strong&gt;: The project I was modeling was created as &lt;strong&gt;Serverless&lt;/strong&gt;, so I selected that option.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After clicking &lt;strong&gt;Review + Create&lt;/strong&gt;, review the options that were set and click &lt;strong&gt;Create&lt;/strong&gt;. Once the deployment is complete, click &lt;strong&gt;Go to resource&lt;/strong&gt; to see the quick start information. This includes the connection string for your instance. I copied the Node version of the connection string.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LNl19sEt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/3c23e997bde6baf2bcdc02ace264787a/5fbb4/azure-5-quick-start.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LNl19sEt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/3c23e997bde6baf2bcdc02ace264787a/5fbb4/azure-5-quick-start.jpg" alt="Azure Cosmos DB quick start" width="880" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on Data Explorer in the left navigation to access the options to create a new database and new collections.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lweqKdH3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/6901645e0b1c4ebad822e88dce3bc1d9/7f446/azure-6-data-explorer.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lweqKdH3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/6901645e0b1c4ebad822e88dce3bc1d9/7f446/azure-6-data-explorer.jpg" alt="Azure Cosmos DB data explorer navigation item" width="337" height="497"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The highest-level container is Database, which Microsoft defines as a "logical container of one or more collections". Choose &lt;strong&gt;New Database&lt;/strong&gt; from the main content dropdown. The single configuration item is &lt;strong&gt;Database id&lt;/strong&gt;, which is simply a unique name; I named my database &lt;strong&gt;Interests&lt;/strong&gt; so I can make collections of data about hobbies and interests I have.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KpNX14PE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/2bd43e18d693507ea4c98b7d4cdab623/16c42/azure-7-new-database.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KpNX14PE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/2bd43e18d693507ea4c98b7d4cdab623/16c42/azure-7-new-database.jpg" alt="Azure Cosmos DB create database" width="476" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the database is created, you will be able to see it in the main content page.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_KL-90I8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/8701e4a7e918a4076bb06ed98f9fccbc/97d16/azure-8-created-database.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_KL-90I8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/8701e4a7e918a4076bb06ed98f9fccbc/97d16/azure-8-created-database.jpg" alt="Azure CosmosDB database created" width="547" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, choose &lt;strong&gt;New Collection&lt;/strong&gt; from the 3 dots menu next to the database to create a collection for that database. The collections will hold documents that contain related information.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8Je-B03_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/508f41e1f197f56777ab1960e11839a6/6f6fc/azure-9-create-new-collection.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8Je-B03_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/508f41e1f197f56777ab1960e11839a6/6f6fc/azure-9-create-new-collection.jpg" alt="Azure Cosmos DB create collection" width="617" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My collection will be about birds, so I selected my &lt;strong&gt;Interests&lt;/strong&gt; database, set &lt;strong&gt;Collection id&lt;/strong&gt; as Birds, left the other default options, and clicked &lt;strong&gt;OK&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UbZLB3R5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/969b417c2bf9b6ab3c267862d5865264/e5641/azure-10-create-new-collection-details.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UbZLB3R5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/969b417c2bf9b6ab3c267862d5865264/e5641/azure-10-create-new-collection-details.jpg" alt="Azure Cosmos DB create collection details" width="443" height="725"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the collection is created, you will be able to see it nested under the database in the main content page.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2tbzYkde--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/f0fb8459b1e896ee381df431e2ce64e6/f7b81/azure-11-created-new-collection.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2tbzYkde--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://kristenkinnearohlmann.dev/static/f0fb8459b1e896ee381df431e2ce64e6/f7b81/azure-11-created-new-collection.jpg" alt="Azure Cosmos DB collection created" width="517" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the database and collection created, it is possible to access the collection and add records one by one, or use the shell to run a query. Since the project I was modeling would do that work from a Node app, I did not create any document records within Azure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a Node app to access the Cosmos DB
&lt;/h2&gt;

&lt;p&gt;The link for the Node tutorial from Azure landed on a page that was no longer in service. I correctly assumed I would be able to easily locate the MongoDB API for Node on &lt;a href="https://www.npmjs.com/"&gt;npm&lt;/a&gt;. The developers for the &lt;a href="https://www.npmjs.com/package/mongodb"&gt;npm MongoDB package&lt;/a&gt; thoughtfully included a really robust tutorial on the page, which I used to build out my sample app.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;After creating a new Node project and installing the &lt;code&gt;mongodb&lt;/code&gt; package, create an &lt;code&gt;app.js&lt;/code&gt; file at the project root for the example code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Require the &lt;code&gt;mongodb&lt;/code&gt; package and declare variables for the connection and database&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;MongoClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mongodb&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// use the value of the Conn string defined for your Cosmos DB resource for this value&lt;/span&gt;
&lt;span class="c1"&gt;// Format: mongodb://samplemongoacct:&amp;lt;GUID&amp;gt;@samplemongoacct.mongo.cosmos.azure.com:&amp;lt;port&amp;gt;/?ssl=true&amp;amp;retrywrites=false&amp;amp;maxIdleTimeMS=120000&amp;amp;appName=@&amp;lt;Cosmos DB account name&amp;gt;@&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&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;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&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;dbName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Interests&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Define an &lt;code&gt;async&lt;/code&gt; function to perform CRUD operations, including the collection name to work with
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Connected successfully to server&lt;/span&gt;&lt;span class="dl"&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;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;client&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="nx"&gt;dbName&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;collection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Birds&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;//// Create&lt;/span&gt;

  &lt;span class="c1"&gt;//// Read&lt;/span&gt;

  &lt;span class="c1"&gt;//// Update&lt;/span&gt;

  &lt;span class="c1"&gt;//// Delete&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Done&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="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;finally&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;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;close&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Implement &lt;code&gt;create&lt;/code&gt; to add document records to work with
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="c1"&gt;//// Create&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;insertResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;insertMany&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Chickadee&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;active&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cardinal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;active&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bluejay&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;active&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sparrow&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;active&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Insert documents:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;insertResult&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Implement &lt;code&gt;read&lt;/code&gt;, both a select of all available documents as well as a filtered select for a specific document
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="c1"&gt;//// Read&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;findResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({}).&lt;/span&gt;&lt;span class="nx"&gt;toArray&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Found documents:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;findResult&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;filteredDocs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Chickadee&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;toArray&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Found documents filtered by Chickadee&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filteredDocs&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Implement &lt;code&gt;update&lt;/code&gt;, update one of my documents to contain a more specific name, then performed a filtered select to confirm
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="c1"&gt;//// Update&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;updateResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;updateOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sparrow&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="na"&gt;$set&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Harris Sparrow&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;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Updated document&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;updateResult&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;filteredDocs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Harris Sparrow&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;toArray&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Found documents filtered by Harris Sparrow&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filteredDocs&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Implement &lt;code&gt;delete&lt;/code&gt; to remove all records from the collection
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="c1"&gt;//// Delete&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;deleteResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deleteMany&lt;/span&gt;&lt;span class="p"&gt;({});&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Deleted documents&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;deleteResult&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The process to set up the Cosmos DB instance and the Node sample app was straightforward. There is a large amount of documentation available to determine syntax and special cases to resolve issues. It was helpful to work through the process on my own and ground my understanding on both the structure and the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/kristenkinnearohlmann/sample-mongodb-cosmosdb"&gt;Sample Node app&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mongodb.com/docs/manual/crud/"&gt;MongoDB CRUD Operations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>azure</category>
      <category>node</category>
      <category>mongodb</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Basic Find Query with Prisma</title>
      <dc:creator>Kristen Kinnear-Ohlmann</dc:creator>
      <pubDate>Mon, 21 Mar 2022 02:55:04 +0000</pubDate>
      <link>https://dev.to/kristenkinnearohlmann/basic-find-query-with-prisma-3hcb</link>
      <guid>https://dev.to/kristenkinnearohlmann/basic-find-query-with-prisma-3hcb</guid>
      <description>&lt;p&gt;For my &lt;a href="https://breeze-lakes-point-2.vercel.app/signin"&gt;Breeze Lakes Point project&lt;/a&gt;, I am using &lt;a href="https://www.prisma.io/"&gt;Prisma&lt;/a&gt; as the &lt;a href="https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping"&gt;ORM&lt;/a&gt; to handle data in my PostgreSQL database. This is the ORM that we used with the sample app from the Frontend Masters workshop I attended, and I found it straightforward with great documentation.&lt;/p&gt;

&lt;p&gt;I am working on a feature to find a specific user in the database and return the data for display in a registration form for editing. The basic &lt;code&gt;findUnique&lt;/code&gt; syntax is quite compact:&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;model&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findUnique&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;lookupField&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;lookupValue&lt;/span&gt;&lt;span class="o"&gt;&amp;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;select&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;returnField1&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;returnField2&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since I am still expanding my &lt;code&gt;user&lt;/code&gt; model, I implemented a simple return object:&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;qry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;GUID&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findUnique&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;qry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;select&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;id&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;username&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;email&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;firstName&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;lastName&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the final returned object, I spread the data object to include a message to confirm the data returned to my route, since this is currently the same data that the session contains:&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;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Found&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the basic framework in place to look up and return data via Prisma, I can work to expand both my &lt;code&gt;user&lt;/code&gt; model and the models planned to hold related data.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>nextjs</category>
      <category>postgres</category>
    </item>
  </channel>
</rss>
