<?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: theBridge2</title>
    <description>The latest articles on DEV Community by theBridge2 (@thebridge2).</description>
    <link>https://dev.to/thebridge2</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%2F455046%2F8621fa10-fb74-4554-927e-584780333142.png</url>
      <title>DEV Community: theBridge2</title>
      <link>https://dev.to/thebridge2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thebridge2"/>
    <language>en</language>
    <item>
      <title>Sequelize seeders for static data</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Tue, 24 Dec 2024 12:38:11 +0000</pubDate>
      <link>https://dev.to/thebridge2/sequelize-seeders-for-static-data-52bi</link>
      <guid>https://dev.to/thebridge2/sequelize-seeders-for-static-data-52bi</guid>
      <description>&lt;p&gt;Very brief post on how to do seeders in sequelize.  Seeders are how you create static data in a database that you want to be present without the users having to create it.&lt;/p&gt;

&lt;p&gt;The goal of this is to add some static data to my very basic task type table in my todo app defined by this model:&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;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sequelize&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;static_task_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;static_task_type&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;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;primaryKey&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;autoIncrement&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;task_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRING&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;allowNull&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="p"&gt;});&lt;/span&gt;
    &lt;span class="nx"&gt;static_task_type&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;associate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;models&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;return&lt;/span&gt; &lt;span class="nx"&gt;static_task_type&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;To create a seeder template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx sequelize-cli seed:generate &lt;span class="nt"&gt;--name&lt;/span&gt; add-static-task-types
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is filling in the seeder template with a couple of task types.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/** @type {import('sequelize-cli').Migration} */&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;up &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;queryInterface&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&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;queryInterface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bulkInsert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;static_task_types&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;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;task_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Deep&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="na"&gt;createdAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="na"&gt;updatedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;task_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Shallow&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="na"&gt;createdAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="na"&gt;updatedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&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="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;task_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Phone Call&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="na"&gt;createdAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="na"&gt;updatedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;task_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Errands&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="na"&gt;createdAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="na"&gt;updatedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&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;async&lt;/span&gt; &lt;span class="nf"&gt;down &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;queryInterface&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&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;queryInterface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bulkDelete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;static_task_types&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;truncate&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;cascade&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Optional: Will also delete dependent rows if foreign keys are used&lt;/span&gt;
      &lt;span class="na"&gt;restartIdentity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Optional: Resets auto-increment counters&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;NOTE: don't forget to add the createdAt and updatedAt columns, otherwise you will get the following error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ERROR: null value &lt;span class="k"&gt;in &lt;/span&gt;column &lt;span class="s2"&gt;"createdAt"&lt;/span&gt; of relation &lt;span class="s2"&gt;"static_urgencies"&lt;/span&gt; violates not-null constraint
ERROR DETAIL: Failing row contains &lt;span class="o"&gt;(&lt;/span&gt;1, Now, null, null&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the seed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx sequelize-cli db:seed:all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Success as shown in DBeaver window:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fond73z37cetso2jxz68k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fond73z37cetso2jxz68k.png" alt="Image description" width="670" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>database</category>
    </item>
    <item>
      <title>Sequelize migrations</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Tue, 24 Dec 2024 12:08:03 +0000</pubDate>
      <link>https://dev.to/thebridge2/sequelize-migrations-2611</link>
      <guid>https://dev.to/thebridge2/sequelize-migrations-2611</guid>
      <description>&lt;p&gt;Given the following sequelize model for my basic todo project's metadata table, I'd like to make some changes using sequelize's migrations.&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;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sequelize&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Metadata&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;metadata&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;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;primaryKey&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;autoIncrement&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;urgencyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;allowNull&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;dataId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;allowNull&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;taskTypeId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;allowNull&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;projectId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;allowNull&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;data_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;allowNull&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;Metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;associate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;models&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;Metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;belongsTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;models&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;foreignKey&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="s1"&gt;data_id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;allowNull&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;hooks&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;onDelete&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cascade&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;return&lt;/span&gt; &lt;span class="nx"&gt;Metadata&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;Sequelize utilizes migration files that are essentially like database commits.  To create a migrations file type in your command line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx sequelize-cli migration:generate &lt;span class="nt"&gt;--name&lt;/span&gt; data-columns-rename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a migrations file with a template in /migrations folder and the name you provided in the command above (in this case data-columns-rename.js with the current date/time in front).&lt;/p&gt;

&lt;p&gt;Template migrations file created for you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/** @type {import('sequelize-cli').Migration} */&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;up &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;queryInterface&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;down &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;queryInterface&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */&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;The &lt;strong&gt;async up&lt;/strong&gt; command is the command it runs to try to make changes to the table, and the &lt;strong&gt;async down&lt;/strong&gt; command runs to remove the changes.  When you do your migrations, make sure the down commands are in reverse.&lt;/p&gt;

&lt;p&gt;In my case, I'm trying to do some column name changes for some basic todo type table information so my filled in migrations table looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/** @type {import('sequelize-cli').Migration} */&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;up &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;queryInterface&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&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;queryInterface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeColumn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;metadata&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dataId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// renameColumn: table, old column name , new column name&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;queryInterface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;renameColumn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;metadata&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;urgencyId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;urgency_id&lt;/span&gt;&lt;span class="dl"&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;queryInterface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;renameColumn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;metadata&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;taskTypeId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;task_type_id&lt;/span&gt;&lt;span class="dl"&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;queryInterface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;renameColumn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;metadata&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;projectId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;project_id&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;async&lt;/span&gt; &lt;span class="nf"&gt;down &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;queryInterface&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&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;queryInterface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addColumn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;metadata&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dataId&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;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;allowNull&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="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;queryInterface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;renameColumn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;metadata&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;urgency_id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;urgencyId&lt;/span&gt;&lt;span class="dl"&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;queryInterface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;renameColumn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;metadata&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;task_type_id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;taskTypeId&lt;/span&gt;&lt;span class="dl"&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;queryInterface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;renameColumn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;metadata&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;project_id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;projectId&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;(These changes are simply me still not being used to snake case as desired by postgres)&lt;/p&gt;

&lt;p&gt;Once the migrations table is ready, run it with this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx sequelize-cli db:migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Among other printouts from running the command, the key text for me to see success is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;==&lt;/span&gt; 20241224113716-metadata-columns-rename: migrating &lt;span class="o"&gt;=======&lt;/span&gt;
&lt;span class="o"&gt;==&lt;/span&gt; 20241224113716-metadata-columns-rename: migrated &lt;span class="o"&gt;(&lt;/span&gt;0.065s&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you can see the changes verified in this screenshot from DBeaver:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8bcjwp1qn30nttfkwl4x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8bcjwp1qn30nttfkwl4x.png" alt=" " width="238" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To run a specific migrations file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx sequelize-cli db:migrate &lt;span class="nt"&gt;--name&lt;/span&gt; 20241224113716-metadata-columns-rename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let me know if there is interest in a post describing the basics of getting started with sequelize.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>database</category>
    </item>
    <item>
      <title>NPM Dependency error</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Mon, 23 Dec 2024 14:14:28 +0000</pubDate>
      <link>https://dev.to/thebridge2/npm-dependency-error-c4a</link>
      <guid>https://dev.to/thebridge2/npm-dependency-error-c4a</guid>
      <description>&lt;p&gt;Making a quick post to remind myself in the future how to read these npm dependency errors.&lt;/p&gt;

&lt;p&gt;Kudos to this stack overflow post:  &lt;a href="https://stackoverflow.com/questions/76039613/how-do-i-read-npm-dependency-conflict-errors" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/76039613/how-do-i-read-npm-dependency-conflict-errors&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is my error with two key parts highlighted:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwlqc5tqv89cy5104b2d1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwlqc5tqv89cy5104b2d1.png" alt="Image description" width="565" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is stating "for &lt;a href="mailto:client@1.0.0"&gt;client@1.0.0&lt;/a&gt; I have installed react 18.3.0 BUT &lt;a href="mailto:react-dom@19.0.0"&gt;react-dom@19.0.0&lt;/a&gt; requires react 19.0.0."&lt;/p&gt;

&lt;p&gt;Ok, so how do we resolve this?  First of all, we need to make sure we understand the npm versioning scheme with the package.json file.&lt;/p&gt;

&lt;p&gt;First step is to understand the semantic versioning system used by npm.  A major version 5, minor version 10, and patch version 3 would be 5.10.3, or:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Semantic versioning = MAJOR.MINOR.PATCH&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From this article &lt;a href="https://flaviocopes.com/npm-semantic-versioning/" rel="noopener noreferrer"&gt;https://flaviocopes.com/npm-semantic-versioning/&lt;/a&gt;  we get the following key points for how npm interprets what libraries and versions to install from your package.json file:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&amp;gt; any version higher than your current version&lt;/li&gt;
&lt;li&gt;^ - allows updating minor and patch releases.  Ex: ^5.1.3. allows updating 5.10.3, but will not allow going to major release 6.&lt;/li&gt;
&lt;li&gt;~ allows only patch releases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simplified version of my package.json file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
"dependencies" : {
  "react": "^18.3.1"
  "@types/react-dom": "^18.2.21",
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the first problem here you see with my package.json file is that there is a new major release out now for react which is major version 19.   My "^" in my package.json will not allow that to be installed.&lt;/p&gt;

&lt;p&gt;To make sure I understood all the new versions I might need to consider in my dependencies I ran the following command&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;npm outdated &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb3c4gr52j0mkh7uax87n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb3c4gr52j0mkh7uax87n.png" alt="Image description" width="425" height="156"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To fix my issues, i updated my package.json file to allow all minor and patch versions of react and react-dom in major version 19:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
"dependencies" : {
  "react": "^19.0.0"
  "@types/react-dom": "^19.0.0",
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also before running the handy npm i command to fix all of this, I deleted my node_modules and package-lock.json folder.  I'm pretty sure this isn't necessary now with npm improvements made over time.  Never hurts to do this when debugging though since both node_modules and package-lock.json get recreated on the install command.&lt;/p&gt;

&lt;p&gt;Now my issues are resolved!  Hope this helps.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>npm</category>
    </item>
    <item>
      <title>Full Stack Javascript Web Development Concept map</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Sat, 23 Mar 2024 17:01:48 +0000</pubDate>
      <link>https://dev.to/thebridge2/full-stack-web-development-concept-map-4m7p</link>
      <guid>https://dev.to/thebridge2/full-stack-web-development-concept-map-4m7p</guid>
      <description>&lt;h1&gt;
  
  
  Concept Map
&lt;/h1&gt;

&lt;p&gt;The full stack web development world and javascript keep moving at a tremendous pace.  This is my attempt to capture some of the higher level concepts, languages and tools that a beginner and intermediate developer should be aware of.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frynddl9gxrrep65prxm8.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frynddl9gxrrep65prxm8.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note - I included some other technologies that are not in my primary stack, but these are the ones I am most familiar with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;Text editor&lt;/u&gt; - VsCode&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;Source control&lt;/u&gt; - Git&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;Package manager&lt;/u&gt; - Npm&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;Javascript technology&lt;/u&gt; - React&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;Server&lt;/u&gt; - Node JS&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;Middleware&lt;/u&gt; - Express&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;ORM&lt;/u&gt; - Sequelize&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;Database&lt;/u&gt; - Was SQL Server, now moving to Postgres&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Writing Code
&lt;/h1&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywj3vwx7gt6t7fcvhur6.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywj3vwx7gt6t7fcvhur6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;text editor&lt;/strong&gt; - a text editor is where you write your code.  These range from command line tools to fully featured tools&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;VsCode&lt;/u&gt; - mainstream text editor.  Has lots of add-ons to enable additional capability&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;Sublime&lt;/u&gt; - slightly more lightweight than vscode&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;Notepad++&lt;/u&gt; - basic text editor with some neat addons.&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;vim&lt;/u&gt; - command line text editor. More powerful than nano.  Two modes, edit, and command mode.&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;nano&lt;/u&gt; - command line text editor.  simpler and less capable than vim. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;source control&lt;/strong&gt; - this is of utmost importance in todays distributed development environment.  Even with a single developer, source control allows careful control over change and the ability to revert back to known working states when things go wrong.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;git&lt;/u&gt; - this is the mainstream development tool.  This runs on your own pc locally and connects to a cloud tool like github or gitlab.
&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;github&lt;/u&gt; - cloud service that is the source for sharing code. &lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Setting up a project
&lt;/h1&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9sqjnvtk64sdoa5iavrt.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9sqjnvtk64sdoa5iavrt.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;command line&lt;/strong&gt; - a way to control the computer with out a graphical interface.  A number of tools must be manipulated with the command line.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;bash&lt;/u&gt; - created in 1989, unix shell and command language.&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;zshell&lt;/u&gt; - or zsh, created in 1990  is a unix shell with improvements over bash including the ability to use shell scripts.  Comes as default language in macOS starting in Catalina.&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;command shell&lt;/u&gt; - windows command line built to automate routine tasks&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;powershell &lt;/u&gt; - windows command line built to extend command shell to run more sophisticated commands called cmdlets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;build tools and bundlers&lt;/strong&gt; - are tools to create your web application&lt;br&gt;
-&lt;u&gt;webpack&lt;/u&gt; - is a tool that takes your source code from your project and converts it to a bundle that can be loaded properly by your browser.&lt;br&gt;
-&lt;u&gt;create react app&lt;/u&gt; - (CRA) is a tool used to create a number of files as a starting point for the project and packages it for deployment.  CRA also uses a webpack under the hood, but the user doesn't have to understand these details.&lt;/p&gt;

&lt;h1&gt;
  
  
  Using others code
&lt;/h1&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3l5rtb848bhed2tth9p.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3l5rtb848bhed2tth9p.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;package manager&lt;/strong&gt; - package managers exist to help distribute all the pieces of code people have published.  Using other peoples code makes writing code faster.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;npm &lt;/u&gt; - stands for Node Package Manager and is the default manager for NodeJS.
&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;yarn&lt;/u&gt; - stands for Yet Another Resource Navigator. Yarn was developed to overcome some issues npm had at the time, but both have kept pace with each other and are very similar in capability.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Running a server
&lt;/h1&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgks7unanv0adfti2tc7.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgks7unanv0adfti2tc7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;virtualization&lt;/strong&gt; - is done to make it easier to distribute an application to multiple hardware environments.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;docker&lt;/u&gt; - is an open platform for developing shipping and running applications.  Docker uses a client server model. &lt;a href="https://docs.docker.com/get-started/overview/" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;podman&lt;/u&gt; - is a daemonless, open source linux native tool designed to deploy applications using containers and images. Podman was designed to be more secure than docker.&lt;a href="https://docs.podman.io/en/latest/" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;environment variables&lt;/strong&gt; - are used primarily to store data the application needs but should not be stored in the source code like user name and password for user and database logins.&lt;/p&gt;

&lt;h1&gt;
  
  
  Javascript Packages
&lt;/h1&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5jsdf9lys0husfpdof89.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5jsdf9lys0husfpdof89.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;People write code to solve problems.  The common problems everyone solves over and over end up in packages that everyone ends up re-using.  Don't be afraid to use other peoples code.  This is just a small sampling of available packages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Front end only&lt;/strong&gt; - These packages are designed to run in your browser not on the backend server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;material UI&lt;/u&gt; - open source library that implements google's styling for html components &lt;a href="https://mui.com/material-ui/getting-started/" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;redux&lt;/u&gt; - Redux is a key tool used in managing state across an application.  This can be used with any web technology including React, Vue and Angular &lt;a href="https://redux.js.org" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;react tables&lt;/u&gt; - react tables is a library that exists for react that make creating tables easier.  There are other competing libraries including one in material UI worth considering. &lt;a href="https://react-tables.com" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;bootstrap&lt;/u&gt; - toolkit for styling websites.  Has lots of themes and capabilities.  &lt;a href="https://getbootstrap.com" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;d3&lt;/u&gt; - very power visualization library enabling dynamic visualizations. &lt;a href="https://d3js.org" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For both front end and backend&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;lodash&lt;/u&gt; - utility library enabling things like deep object comparison that aren't easy to do with javascript out of the box. &lt;a href="https://lodash.com" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;package.json&lt;/u&gt; - file used for a number of things including saving your dependencies for both front and backend, so that your package manager can easily install the packages you need on another machine.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Backend only&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;nodemon&lt;/u&gt; - enables automatic reload of your server after code change &lt;a href="https://nodemon.io" rel="noopener noreferrer"&gt;docs&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;u&gt;rimraf&lt;/u&gt; - enables easy deleting of server files including npm packages and optimized build files&lt;a href="https://github.com/isaacs/rimraf#readme" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Front End
&lt;/h1&gt;

&lt;p&gt;Also referred to as the client.  The front end is what runs in your browser and can be run on many different computers at the same time.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7fa2tigx1k5vu4cfzk1l.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7fa2tigx1k5vu4cfzk1l.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Document object model&lt;/strong&gt; - connects web pages to scripts by representing the structure of the page in memory. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structure&lt;/strong&gt; - the structure of your webpage is important&lt;br&gt;
&lt;u&gt;HTML&lt;/u&gt; - (HyperText Markup Language)  is the code used to structure a web page and its content. &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Styling&lt;/strong&gt; - The difference between a webpage that looks great and one that looks outdated is almost always the styling.&lt;br&gt;
&lt;u&gt;CSS&lt;/u&gt; - Cascading Style Sheet allows you to format your webpage with color, size, spacing.  &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Images&lt;/strong&gt; - A picture is worth 1,000 words, using image on a webpage is key to rich content.&lt;br&gt;
&lt;u&gt;SVG&lt;/u&gt; - Uses geometric shapes to render graphics.  Resolution independent. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/SVG" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;br&gt;
&lt;u&gt;XML&lt;/u&gt; - stands for Extensible Markup Language and is similar to HTML but has no predefined tags to use.  SVG stores its data in XML. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;br&gt;
&lt;u&gt;Canvas&lt;/u&gt; - Canvas uses pixels.  Gets blurry when resized.  Can be more performant. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Javascript in the browser&lt;/strong&gt;&lt;br&gt;
&lt;u&gt;React&lt;/u&gt; - react is a library that gives developers an application programming interface (API) to manipulate the DOM (this is React's ReactDOM package).  React uses components and JSX to make building reusable code easier. &lt;a href="https://react.dev" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;br&gt;
&lt;u&gt;JSX&lt;/u&gt; - is a syntax extension for React Javascript code that lets you write HTML-like markup in a javascript file.  This makes it easier to write reusable HTML. &lt;a href="https://react.dev/learn/writing-markup-with-jsx" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;br&gt;
&lt;u&gt;State&lt;/u&gt; - a key react concept that guides setting and storage of data between renders. &lt;a href="https://react.dev/learn/updating-objects-in-state" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;br&gt;
&lt;u&gt;Hooks&lt;/u&gt; - a key react concept for logic triggered by state change &lt;a href="https://react.dev/reference/react-dom/hooks" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;br&gt;
&lt;u&gt;Vue&lt;/u&gt; - is a framework for building web interfaces.  Vue is lightweight and best for small projects prioritizing speed over functionality.  &lt;a href="https://vuejs.org" rel="noopener noreferrer"&gt;doc&lt;/a&gt;&lt;br&gt;
&lt;u&gt;Angular&lt;/u&gt; - web development framework.  Angular is best for dynamic more feature rich sites. &lt;a href="https://angular.io" rel="noopener noreferrer"&gt;docs&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Note: React vs Vue/Angular - The key difference between React and Vue/Angular is that react is a library not a framework and therefore requires you to do more work to build your project in library and tool selection.  Vue/Angular are frameworks with reduced choices for project setup.  Vue/Angular should generally be easier to learn but less flexible than React which is harder to learn but much more flexible.&lt;/p&gt;

&lt;h1&gt;
  
  
  Networking
&lt;/h1&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6i6v6uc4jibt8v70uopt.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6i6v6uc4jibt8v70uopt.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To connect the front end with the backend you have to have some understanding of networking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ip addresses&lt;/strong&gt; - IP stands for internet protocol.  An ip address is a string of characters that identifies each computer on a network. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;localhost&lt;/strong&gt; - is the ip address of the current system you are developing on.  This is the ip address used most commonly in development. The address 'localhost' and 127.0.0.1 are equivalent.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNS&lt;/strong&gt; - stands for Domain Name System which is a lookup table between domains we know like google.com and IP addresses like 104.234.123.11.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IPV4&lt;/strong&gt; - is the 4th generation of the internet protocol.  IPv4 is in the format X.X.X.X where each X can be any value between 0 and 255.  IPv4 has 4.29 billion possible combinations (which has now been reached)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IPV6&lt;/strong&gt; - is the 6th generation of the internet protocol.  The key change is to create more available addresses.  Using 128-bit addresses vs IPv4s 32 bit addresses, IPv6 can support 2^128 internet addresses, which is a lot.  IPv6 format is xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;port&lt;/strong&gt; - a port is the connection point of network connections.  Each port is associated with a specific process or service.  If you don't have the right ip addresses and ports, you will not be able to access your front end via the browser and your front end won't connect to the backend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Subnet mask&lt;/strong&gt; - a subnet mask is used to identify which network an IP address belongs to.  Subnet masks can be created to create subnetworks that can't see each other.  Often if networking issues happen, one needs to understand subnet masks to make sure two computers are on the same network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Networking tools&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;ping&lt;/u&gt; - the most basic tool, that answers the question, "can I see a computer through a network?"&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;browser network tab&lt;/u&gt; - a more advanced tool that can be used inside the developer tools in a browser.  This will show data received and sent to the browser.&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;wireshark&lt;/u&gt; - a very advanced network tool that allows you to see all the packet traffic in a network.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Back End
&lt;/h1&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Filnarmpsgail8r8u992x.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Filnarmpsgail8r8u992x.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server&lt;/strong&gt; - a computer that provides functionality for other programs and devices called clients.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;nodeJS&lt;/u&gt; - the mainstream javascript server choice. &lt;a href="https://nodejs.org/en" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Middleware&lt;/strong&gt; - middleware is the layer between the response and the request.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;express&lt;/u&gt; - one of the most popular middleware tools, lightweight and easy to learn. &lt;a href="https://expressjs.com" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;NestJS&lt;/u&gt; - opinionated more scalable, but harder to learn &lt;a href="https://nestjs.com" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;ORM&lt;/strong&gt; - stands for object relational mapping.  This enables you to write less SQL and makes Create, Read, Update, Delete (CRUD) operations much faster for a developer to implement.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;Sequelize&lt;/u&gt; - modern Typescript and NodeJS ORM for Oracle, Postgres, MySQL, MariaDB, SQLite, SQL Server+&lt;a href="https://sequelize.org" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Typescript
&lt;/h1&gt;

&lt;p&gt;Typescript can be used in both the front end and the back end and gives strong typing to javascript for easier error prevention.  The learning curve can be difficult at times but the benefits are worth it! &lt;a href="https://www.typescriptlang.org" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;This took me a while to build these concepts and relationships in my head.  Hopefully they are helpful for some of you still trying to understand the fundamentals of full stack web development.&lt;/p&gt;

&lt;p&gt;Let me know if there are more concepts you think I should include.  Obviously at some point this becomes more advanced.  I did introduce some advanced concepts, but I think you have to hear about things several times before you make the effort to learn them.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>fullstack</category>
    </item>
    <item>
      <title>Run PostgreSQL in docker</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Sat, 23 Mar 2024 02:56:16 +0000</pubDate>
      <link>https://dev.to/thebridge2/run-postgresql-in-docker-4f3i</link>
      <guid>https://dev.to/thebridge2/run-postgresql-in-docker-4f3i</guid>
      <description>&lt;p&gt;Overview&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi49jo990ug8eerd5bgse.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi49jo990ug8eerd5bgse.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  1) Setting up
&lt;/h1&gt;

&lt;p&gt;Get docker&lt;br&gt;
&lt;a href="https://www.docker.com/get-docker" rel="noopener noreferrer"&gt;https://www.docker.com/get-docker&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go to terminal to prove the install succeeded.&lt;/p&gt;

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

docker --help


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Get postgres image to use in docker.&lt;br&gt;
&lt;a href="https://hub.docker.com/_/postgres" rel="noopener noreferrer"&gt;https://hub.docker.com/_/postgres&lt;/a&gt;&lt;/p&gt;

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

docker pull postgres:alpine


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is the smallest postgres install image to use for testing.&lt;/p&gt;

&lt;h1&gt;
  
  
  2) Start docker postgres container
&lt;/h1&gt;

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

docker run --name any_image_name -e POSTGRES_PASSWORD=mypassword -d -p 5432:5432 postgres


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;-&amp;gt; -e creates an environment variable&lt;br&gt;
-&amp;gt; -p 5432:5432 exposes port 5432 to external to the container&lt;/p&gt;

&lt;h1&gt;
  
  
  3) Test docker image with psql
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://dev.to/thebridge2/postgres-command-line-psql-3f4n"&gt;Link to my PostgreSQL cheat sheet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Useful reference:  &lt;a href="https://stackoverflow.com/questions/37694987/connecting-to-postgresql-in-a-docker-container-from-outside" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/37694987/connecting-to-postgresql-in-a-docker-container-from-outside&lt;/a&gt;&lt;/p&gt;

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

docker ps     # Get container id
docker exec -it container_id bash  #Connect to docker container using bash prompt


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Inside of docker container bash prompt&lt;/p&gt;

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

psql -U postgres # connect to postgres


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Inside of a successful postgres connection with psql in docker container&lt;/p&gt;

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

CREATE DATABASE test;  #Create database
\list  # verify database created successfully
\q  # Quit
Control+C. #Exit out of bash shell inside docker container


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Test from outside docker container:&lt;/p&gt;

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

psql -h localhost -p 5432 -U postgres
\list  # see the database you created.


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Troubleshooting
&lt;/h1&gt;

&lt;p&gt;This section is mac os/linux specific.  For windows, you will need to find the corresponding troubleshooting commands.&lt;/p&gt;
&lt;h3&gt;
  
  
  Port issues
&lt;/h3&gt;

&lt;p&gt;IF port error - debug ports in use with  this command&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo lsof -i -P | grep LISTEN | grep :5432   


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you find anything like postgres or anything else listening  on the port, run &lt;/p&gt;

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

sudo kill process_id


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;where process id is the second column of what was returned from the above lsof command.&lt;/p&gt;

&lt;p&gt;Check to see if other docker containers are running trying to use the same port&lt;/p&gt;

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

docker ps -a  # get list of all containers
docker stop container_id
docker rm container_id


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Other instances of postgres running
&lt;/h3&gt;

&lt;p&gt;Check services running&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

brew services list


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If anything running with brew you need to kill, run &lt;/p&gt;


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

&lt;p&gt;brew services stop service_name&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  4) Connect with python, node JS etc.&lt;br&gt;
&lt;/h1&gt;

&lt;p&gt;Now that you proved you can connect to your docker containerized postgres instance, you can use your normal approaches to connect to postgres not inside a docker container.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>postgres</category>
      <category>docker</category>
    </item>
    <item>
      <title>PostgreSQL command line psql cheat sheet</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Thu, 21 Mar 2024 00:10:41 +0000</pubDate>
      <link>https://dev.to/thebridge2/postgres-command-line-psql-3f4n</link>
      <guid>https://dev.to/thebridge2/postgres-command-line-psql-3f4n</guid>
      <description>&lt;h2&gt;
  
  
  Tools Overview
&lt;/h2&gt;

&lt;p&gt;postgres = open source relational database software&lt;br&gt;
psql = command line tool to connect to postgres&lt;br&gt;
pgAdmin = web based tool front end to psql - not discussing here&lt;/p&gt;

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

&lt;p&gt;This cheat sheet is for psql.  Other 3rd party tools exist for connecting to postgres databases.  (Dbeaver is a popular choice)&lt;/p&gt;

&lt;h1&gt;
  
  
  Postgres cmd line tool psql
&lt;/h1&gt;

&lt;p&gt;Official docs&lt;br&gt;
&lt;a href="https://www.postgresql.org/docs/current/app-psql.html"&gt;https://www.postgresql.org/docs/current/app-psql.html&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;psql --help&lt;/td&gt;
&lt;td&gt;list help&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;psql --username=postgres&lt;/td&gt;
&lt;td&gt;login to postgres cmd line&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;When logged in:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;\list&lt;/td&gt;
&lt;td&gt;print out list of databases&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\c &amp;lt;db name&amp;gt;&lt;/td&gt;
&lt;td&gt;connect to a certain database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\dt&lt;/td&gt;
&lt;td&gt;show all tables in current schema&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\df&lt;/td&gt;
&lt;td&gt;list functions of current database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\dv&lt;/td&gt;
&lt;td&gt;list views of current database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\du&lt;/td&gt;
&lt;td&gt;list users and roles&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\q&lt;/td&gt;
&lt;td&gt;quit postgres cmd line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SELECT * from mytable;&lt;/td&gt;
&lt;td&gt;select statement to table&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>postgres</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>NodeJS Backend tools - Node Version Manager (NVM)</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Thu, 07 Dec 2023 18:49:36 +0000</pubDate>
      <link>https://dev.to/thebridge2/nodejs-backend-tools-node-version-manager-nvm-116g</link>
      <guid>https://dev.to/thebridge2/nodejs-backend-tools-node-version-manager-nvm-116g</guid>
      <description>&lt;p&gt;Here is a very basic page on NVM.  If you don't know what NVM is and you use nodeJS, you should know!&lt;/p&gt;

&lt;h1&gt;
  
  
  NVM
&lt;/h1&gt;

&lt;p&gt;Node version manager is very powerful allowing you to easily install and switch back and forth between different node versions.&lt;/p&gt;

&lt;p&gt;Install nvm per instructions.&lt;br&gt;
&lt;a href="https://github.com/nvm-sh/nvm"&gt;https://github.com/nvm-sh/nvm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(I used their curl command to download script and run)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Node install with nvm:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;node -v. # is v20.10.0 at this point.&lt;/li&gt;
&lt;li&gt;nvm install 16   #installs node v16 and switches to it.&lt;/li&gt;
&lt;li&gt;node -v   # now equals v16.20.2.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To switch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;nvm use 20   # (may need to install 20 with nvm for it to be able to use it)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>tools</category>
      <category>node</category>
    </item>
    <item>
      <title>Javascript datetime to and from postgres with time zone</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Wed, 01 Nov 2023 10:39:45 +0000</pubDate>
      <link>https://dev.to/thebridge2/javascript-to-and-from-postgres-datetime-with-timezone-eif</link>
      <guid>https://dev.to/thebridge2/javascript-to-and-from-postgres-datetime-with-timezone-eif</guid>
      <description>&lt;p&gt;First of all, shout out to this blog that goes much deeper into this and is how I learned this concept:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.untrod.com/2016/08/actually-understanding-timezones-in-postgresql.html"&gt;https://blog.untrod.com/2016/08/actually-understanding-timezones-in-postgresql.html&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Problem:
&lt;/h1&gt;

&lt;p&gt;Inserting a datetime from js to postgres and then selecting that same time back out will likely end up with the wrong timezone on your select statement unless you know what you are doing.  This happens even if you are inserting UTC and attempting to select UTC.&lt;/p&gt;

&lt;p&gt;Specifically what happened to me and the blog post above is instead of getting UTC back, I got UTC + 2 x my UTC offset, which is very very wrong.&lt;/p&gt;

&lt;h1&gt;
  
  
  Bad solution:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Use AT TIME ZONE 'UTC' in select statements.
Ex: SELECT log_time AT TIME ZONE 'UTC' as log_time_utc FROM logs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is bad because you will have to do this everywhere you use log_time.  Lets find a better solution that just works as expected.&lt;/p&gt;

&lt;h1&gt;
  
  
  Solution:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Use timestamptz as your database column definition (which is timezone aware, vs just timestamp which is not)&lt;/li&gt;
&lt;li&gt;Put a timezone offset string at the end of your datetime value prior to inserting, otherwise postgres won't understand what is being inserted (even for UTC you must put a "+0")&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
In my javascript helper utilities before inserting a new date, which are created with local time, I have been converting to UTC time.&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;function&lt;/span&gt; &lt;span class="nx"&gt;makeDateTimeNowForDbUtc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inDate&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;inDate&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;inDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;outDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;inDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getUTCFullYear&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;-&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;00&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getUTCMonth&lt;/span&gt;&lt;span class="p"&gt;()&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="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;-&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;00&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getUTCDate&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;00&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getHours&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;00&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getUTCMinutes&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; 
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;00&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getUTCSeconds&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;00&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getUTCMilliseconds&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;outDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;outDate&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="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// addition for postgres&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;outDate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I don't have to worry about it and my dates go in as UTC and back out as UTC without any additional code!&lt;/p&gt;

&lt;p&gt;NOTE: if you are getting confused by the time zone offset in the javascript date time use toUTCString to get straight UTC time from your date.&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;let&lt;/span&gt; &lt;span class="nx"&gt;dt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;myPostgresSelectReturn&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="s1"&gt;UTC Value: &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toUTCString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// Date time GMT where GMT = UTC&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hope this helps!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>postgres</category>
    </item>
    <item>
      <title>Python fundamentals (1 of 2): How to install and run python</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Fri, 27 Oct 2023 13:47:04 +0000</pubDate>
      <link>https://dev.to/thebridge2/python-fundamentals-how-to-install-and-run-python-1358</link>
      <guid>https://dev.to/thebridge2/python-fundamentals-how-to-install-and-run-python-1358</guid>
      <description>&lt;h1&gt;
  
  
  Installing python
&lt;/h1&gt;

&lt;p&gt;To install python, go to the python downloads page:  &lt;a href="https://www.python.org/downloads/"&gt;https://www.python.org/downloads/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To see python version installed, type python -VV  in the command line.&lt;/p&gt;

&lt;p&gt;To see which version of python you are running and where it is installed in linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -l $(which python)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Where do I run python?
&lt;/h1&gt;

&lt;p&gt;Once python is installed, you can run python from several places.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run python with IDLE
&lt;/h2&gt;

&lt;p&gt;When you install python you get the Integrated Development and Learning Environment (IDLE) which is where most beginners start writing programs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HE0j71rs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qs50iekg3m76yyl62oe6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HE0j71rs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qs50iekg3m76yyl62oe6.png" alt="Image description" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are going to write a program with any complexity however, I would recommend you use an IDE like vs code that allows you to set breakpoints and pause program execution.  This is possible in IDLE, but it is fairly rudimentary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run python with VS Code
&lt;/h2&gt;

&lt;p&gt;Download vs code from &lt;a href="https://code.visualstudio.com/download"&gt;https://code.visualstudio.com/download&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add the python extension to VS Code, by clicking on the extensions side button:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SMNnL_Ub--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wn9xrpi5lh0kfw3si4a5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SMNnL_Ub--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wn9xrpi5lh0kfw3si4a5.png" alt="Image description" width="161" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and searching for python.  The correct python package to install is this one:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bi6fMcPf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyjzrxaywuqhiu40jtse.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bi6fMcPf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyjzrxaywuqhiu40jtse.png" alt="Image description" width="800" height="556"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then go ahead and create a hello world python file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print('hello world!')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now hit 'F5' to run it in VS Code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XyjonMtM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ujd48b69pi97bxkqo4l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XyjonMtM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ujd48b69pi97bxkqo4l.png" alt="Image description" width="800" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select "Python File Debug the currently active python file" and it will run.&lt;/p&gt;

&lt;p&gt;This will run in the terminal at the bottom of VS Code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pSXJSyMg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xpafk6ehrrkml02zp0xp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pSXJSyMg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xpafk6ehrrkml02zp0xp.png" alt="Image description" width="733" height="730"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: if you use break points in vs code and want to see the value of variables or run python commands while the program is paused, go to the debug console at the bottom and start typing away!  See below for an example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aw39sPbu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/so0w9k2esx9549sp0pqw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aw39sPbu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/so0w9k2esx9549sp0pqw.png" alt="Image description" width="621" height="511"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Run python inside a shell
&lt;/h2&gt;

&lt;p&gt;Python shell is created from your command line tool by typing in "python".  You are rewarded with '&amp;gt;&amp;gt;&amp;gt;' to indicate you are properly in a python shell.&lt;/p&gt;

&lt;p&gt;If this doesn't work for you, and you get an error like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WKET54j5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1g02vmrs3t8inxk5l4gm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WKET54j5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1g02vmrs3t8inxk5l4gm.png" alt="Image description" width="712" height="69"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;then the problem is that you need to add this to your operating system's path variable.  &lt;/p&gt;

&lt;p&gt;See part 2 for how to figure out path variable issues.  &lt;a href="https://dev.to/thebridge2/python-basics-1-of-n-how-to-run-python-and-install-packages-path-variable-1dc2"&gt;Part 2 - Python Fundamentals: Install packages and dealing with PATH variables&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>Basic Mac development setup</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Mon, 09 Oct 2023 11:13:00 +0000</pubDate>
      <link>https://dev.to/thebridge2/basic-mac-development-setup-4hj1</link>
      <guid>https://dev.to/thebridge2/basic-mac-development-setup-4hj1</guid>
      <description>&lt;p&gt;All of my development has been on a windows machine to this point having only casually used my Mac for 10+ years.&lt;/p&gt;

&lt;p&gt;Even with all that casual experience, I have been tripping up a lot.  Here are the key things that got me going developing on a Mac.&lt;/p&gt;

&lt;h1&gt;
  
  
  Keyboard basics
&lt;/h1&gt;

&lt;p&gt;Using a windows keyboard for now.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Keys&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Command button&lt;/td&gt;
&lt;td&gt;Windows key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Home&lt;/td&gt;
&lt;td&gt;command + left arrow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;End&lt;/td&gt;
&lt;td&gt;command + right arrow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;move cursor one word at a time&lt;/td&gt;
&lt;td&gt;Alt + Arrow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;show applications/desktops&lt;/td&gt;
&lt;td&gt;Control+Up&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Screenshot entire desktop&lt;/td&gt;
&lt;td&gt;Shift + Cmd + 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Screenshot portion of screen&lt;/td&gt;
&lt;td&gt;Shift + Cmd + 4 (+drag cross hair &amp;amp; make a box)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copy&lt;/td&gt;
&lt;td&gt;command + C&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cut&lt;/td&gt;
&lt;td&gt;command + X&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Paste&lt;/td&gt;
&lt;td&gt;command + V&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;More on screenshots&lt;br&gt;
&lt;a href="https://support.apple.com/en-us/HT201361"&gt;https://support.apple.com/en-us/HT201361&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Vscode install
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://code.visualstudio.com/docs/setup/mac"&gt;https://code.visualstudio.com/docs/setup/mac&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Vscode permissions
&lt;/h1&gt;

&lt;p&gt;VS Code won't let you use the terminal until you do this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;OS Settings&amp;gt;Security and privacy&amp;gt;Privacy tab, Click checkbox "documents folder" under Vscode icon.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1&gt;
  
  
  Command line basics
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;pwd&lt;/td&gt;
&lt;td&gt;present working directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ls&lt;/td&gt;
&lt;td&gt;show directory contents&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ls -a&lt;/td&gt;
&lt;td&gt;show all files and directories including hidden ones.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ls -l&lt;/td&gt;
&lt;td&gt;show ownership and permissions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;find . -name 'mystring*'&lt;/td&gt;
&lt;td&gt;find file name containing a string.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;which &amp;lt;app name&amp;gt;&lt;/td&gt;
&lt;td&gt;figure out if and where an application is installed. ex: Is brew installed?  % which brew&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h1&gt;
  
  
  Homebrew Mac/Linux Installer
&lt;/h1&gt;

&lt;p&gt;"The Missing Package Manager for macOS (or Linux)"&lt;br&gt;
&lt;a href="https://brew.sh/"&gt;https://brew.sh/&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;brew list&lt;/td&gt;
&lt;td&gt;list all applications installed with homebrew&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;brew install &lt;/td&gt;
&lt;td&gt;install an application&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h1&gt;
  
  
  Environment Variables and path
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;env&lt;/td&gt;
&lt;td&gt;See all environment variables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;echo $PATH&lt;/td&gt;
&lt;td&gt;See just the path variable&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Add application temporarily to PATH variable&lt;/strong&gt;, so it works right away (ex: postgres):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PATH="$PATH:/Applications/Postgres.app/Contents/Versions/12/bin"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Add application permanently to PATH variable&lt;/strong&gt;, so it works after restarting the terminal and stays:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open your bash profile file at $HOME/.bash_profile with:
$ vi ~/.bash_profile&lt;/li&gt;
&lt;li&gt;At the end of the bash profile, add the line:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PATH="$PATH:/Applications/Postgres.app/Contents/Versions/12/bin"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hope some find this useful.  Plenty more to add I'm sure.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Python fundamentals (2 of 2): How to install packages and deal with PATH variable.</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Fri, 22 Sep 2023 14:09:21 +0000</pubDate>
      <link>https://dev.to/thebridge2/python-basics-1-of-n-how-to-run-python-and-install-packages-path-variable-1dc2</link>
      <guid>https://dev.to/thebridge2/python-basics-1-of-n-how-to-run-python-and-install-packages-path-variable-1dc2</guid>
      <description>&lt;p&gt;If you missed it, consider first checking out my first part  &lt;a href="https://dev.to/thebridge2/python-fundamentals-how-to-install-and-run-python-1358"&gt;Python fundamentals part 1 - installing and running&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Package installation is a fairly straightforward process thanks to the Python's Preferred Installer Program or pip for short.&lt;/p&gt;

&lt;p&gt;However, it seems most explanations assume you understand how to get the PATH variable which is required to get anything to run on the command line.  Lets cover basic install first then the PATH variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful install related commands
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;pip install packageName&lt;/td&gt;
&lt;td&gt;installs some package&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pip uninstall packageName&lt;/td&gt;
&lt;td&gt;uninstalls some package&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pip list&lt;/td&gt;
&lt;td&gt;lists packages installed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;packageName --version&lt;/td&gt;
&lt;td&gt;displays version of installed package&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pip install --upgrade pip&lt;/td&gt;
&lt;td&gt;upgrade the pip&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pip show packageName&lt;/td&gt;
&lt;td&gt;Prints useful list of info about package including where the package is installed on your computer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Installing a package
&lt;/h2&gt;

&lt;p&gt;Let's start with the well known numpy library used for mathematical operations.&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="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If this fails, you will get the error: "No module named 'numpy'"&lt;/p&gt;

&lt;p&gt;The simple solution is to install the module.  Every site everywhere explains this.  The command is:&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="n"&gt;pip3&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that the '3' in pip3 is for python 3.&lt;/p&gt;

&lt;p&gt;To prove you installed it type the command 'pip3 list' and you will see packages that are installed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WUlYzHzb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/azum0e6tflh86ramejfn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WUlYzHzb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/azum0e6tflh86ramejfn.png" alt="Image description" width="255" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Installing a package to be used on command line: pytest
&lt;/h1&gt;

&lt;p&gt;I'm going to be using the python package pytest since it is a harder example and will require an understanding of the PATH variable.&lt;/p&gt;

&lt;p&gt;Here is the basic install command for python to be run in the command prompt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip3 install pytest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then to confirm it works you can type:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If this is the first time you are doing this, more than likely this will fail.  And you will get the same error trying to run it as you would if it wasn't installed at all.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---eZtUVoQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/szwrdu24hl3cpjig7ff3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---eZtUVoQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/szwrdu24hl3cpjig7ff3.png" alt="Image description" width="705" height="49"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go back and take a look at text printed from the install messages and likely you will find something that looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NqrpgDni--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/268nncnhyxed70kcn69j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NqrpgDni--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/268nncnhyxed70kcn69j.png" alt="Image description" width="800" height="40"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;which tells you something about a potential PATH issue.&lt;/p&gt;

&lt;p&gt;What is the PATH variable?&lt;/p&gt;

&lt;h1&gt;
  
  
  Command line PATH variable
&lt;/h1&gt;

&lt;p&gt;PATH is an environment variable.  Environment variables are variables set outside of your code. &lt;br&gt;
For python packages to be able to be used on the command line, it must know where they are.  Generally python packages are installed in a scripts subdirectory next to your python.exe.  See below for more details.&lt;/p&gt;

&lt;p&gt;When you run the command line in any OS, it will not inherently understand what python or other commands not embedded in the OS are.  In order to tell the command line what python is, you will need to add the executable file for python to command line tool's PATH variable.&lt;/p&gt;
&lt;h3&gt;
  
  
  Windows
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo %PATH%  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Linux
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo ${PATH}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This prints all of the places the command line will look for commands.&lt;/p&gt;

&lt;p&gt;When the command line looks for these command definitions it will look through the list of paths and stop when it is found.  So if you have more than one version of python installed, it will find the first version installed and use that one.  If you have more than one version of python installed and want explicit control over which one it uses, you should use a python virtual environment.&lt;/p&gt;
&lt;h1&gt;
  
  
  How do I fix my PATH issue?
&lt;/h1&gt;

&lt;p&gt;To solve your PATH issue for your python command like pytest that needs to be run on the command line, follow these brief steps.  For steps 1 &amp;amp; 2 for more detail I found this video to be useful: &lt;a href="https://www.youtube.com/watch?v=3J96_vyfx8Y"&gt;https://www.youtube.com/watch?v=3J96_vyfx8Y&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is another good reference: &lt;a href="https://realpython.com/add-python-to-path/"&gt;https://realpython.com/add-python-to-path/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;p&gt;1) Find your installed package location.  Generally it is next to your python.exe location and then navigate into the subdirectory /scripts.  Take a look at the PATH error in yellow above.  Sometimes on windows it is installed to your roaming directory.&lt;br&gt;&lt;br&gt;
2) Copy and paste this pip path folder name to your environment variables both in the user and system variables section under PATH&lt;br&gt;
3) Restart your command prompt to get the new system variables update&lt;br&gt;
4) &amp;gt;pip uninstall pytest &lt;br&gt;
5) &amp;gt;pip install pytest&lt;br&gt;
6) pytest -h  # should now work!&lt;/p&gt;

&lt;p&gt;After fixing the path issue, now we get a wall of text in response to our pytest -h in the command line instead of our error.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JzFCo7IE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgkkksxy3o4zsub034pj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JzFCo7IE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgkkksxy3o4zsub034pj.png" alt="Image description" width="800" height="482"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  I installed the package but it still isn't found!?
&lt;/h1&gt;

&lt;p&gt;Type 'pip3 list -v' to see where the packages are installed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jJmpwBqn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6namnevi9boieliiadat.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jJmpwBqn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6namnevi9boieliiadat.png" alt="Image description" width="800" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To figure out where python is actually looking for imports use this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import sys
print(sys.path)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the list does not include your package install path you can either reinstall it to the right location or modify your path with sys.path.append.  Sys.path.append is not best practice, but it is simplest for a new python programmer to get started with.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))) "/../someFolder)
# where __file__ refers to the current file and can be replaced with a relative path
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Best practice is to use some kind of virtual environment like venv or docker.&lt;/p&gt;

&lt;p&gt;My next article will be on using a virtual environment to manage dependencies.  Until then, you can use this for reference:  &lt;a href="https://realpython.com/python-virtual-environments-a-primer/"&gt;https://realpython.com/python-virtual-environments-a-primer/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>Carriage Return line feed: CRLF - Linux vs Windows</title>
      <dc:creator>theBridge2</dc:creator>
      <pubDate>Sat, 24 Jun 2023 11:55:20 +0000</pubDate>
      <link>https://dev.to/thebridge2/carriage-return-line-feed-crlf-linux-vs-windows-482i</link>
      <guid>https://dev.to/thebridge2/carriage-return-line-feed-crlf-linux-vs-windows-482i</guid>
      <description>&lt;p&gt;CRLF?  Carriage return (CR) and line feed (LF) come from the days of typewriters.&lt;/p&gt;

&lt;h1&gt;
  
  
  History
&lt;/h1&gt;

&lt;p&gt;CR = '\r' = 0x0D (HEX) was used to move the cursor to the beginning of the line&lt;/p&gt;

&lt;p&gt;LF = '\n' = 0x0A (HEX) was used to move the cursor down to the next line.&lt;/p&gt;

&lt;p&gt;The combination of CRLF in type writers is what moved the cursor from the end of the current row to the start of the next row.&lt;/p&gt;

&lt;h1&gt;
  
  
  Windows vs Linux file compatibility
&lt;/h1&gt;

&lt;p&gt;As computers developed linux moved away from using both CRLF and just used LF to indicate a new line inside a file while windows continued to use both.&lt;/p&gt;

&lt;p&gt;If a file has only '\n' (LF) for its line endings then it is linux compatible.&lt;br&gt;
If a file has '\r\n' (CRLF) for its line endings then it is windows compatible.&lt;/p&gt;

&lt;p&gt;To convert from linux to windows use the sed command in a linux terminal:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s1"&gt;'s/$/\r/'&lt;/span&gt; fileLinux.txt


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To convert from windows to linux, use the following command in a linux terminal:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;tr&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'\r'&lt;/span&gt; &amp;lt;fileWindows.txt &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; fileLinux.txt


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;credit:  &lt;a href="https://www.commandlinewizardry.com/post/removing-windows-line-breaks" rel="noopener noreferrer"&gt;https://www.commandlinewizardry.com/post/removing-windows-line-breaks&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  How do I know which line ending a file has?
&lt;/h1&gt;

&lt;p&gt;Notepad ++ does it:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftme4c6rgjfmzhzjvvfrx.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftme4c6rgjfmzhzjvvfrx.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;VsCode will show you what the line endings are for a given file at the bottom right of the screen.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffo775ygd0vcg90yq41u5.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffo775ygd0vcg90yq41u5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
