<?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: Aryse Gabrielle Pagano</title>
    <description>The latest articles on DEV Community by Aryse Gabrielle Pagano (@medic1111).</description>
    <link>https://dev.to/medic1111</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%2F969896%2F89ccb445-618a-4e5c-be71-8e5f581f5eee.png</url>
      <title>DEV Community: Aryse Gabrielle Pagano</title>
      <link>https://dev.to/medic1111</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/medic1111"/>
    <language>en</language>
    <item>
      <title>Mongoose DB Seed (node/express)</title>
      <dc:creator>Aryse Gabrielle Pagano</dc:creator>
      <pubDate>Mon, 26 Dec 2022 18:47:18 +0000</pubDate>
      <link>https://dev.to/medic1111/mongoose-db-seed-nodeexpress-3gfh</link>
      <guid>https://dev.to/medic1111/mongoose-db-seed-nodeexpress-3gfh</guid>
      <description>&lt;p&gt;How do you handle seeding DB during development? When working with mock data during development you constantly find yourself resetting the DB, clearing or manually adding entries to it only to eventually have to clear it again, etc...&lt;br&gt;
If that sounds like you, Here's a mini application that will help you.&lt;/p&gt;

&lt;p&gt;Suppose you have an array of objects (your mock data) stored in a file somewhere server-side.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mockUsers = [
  {
    username: "fakemedic",
    email: "med@med.com",
    password: "$2b$10$h036pK1tWvpYRB3Evbq9j.nk57Zh.OwWtzHXTQhgBbaRhS4LIitsC",
    avatar:
      "https://images.unsplash.com/photo-1463453091185-61582044d556?ixlib=rb-4.0.3&amp;amp;ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8cmFuZG9tJTIwcGVyc29ufGVufDB8fDB8fA%3D%3D&amp;amp;w=1000&amp;amp;q=80",
  },
  {
    username: "freesoul",
    email: "free@free.com",
    password: "$2b$10$h036pK1tWvpYRB3Evbq9j.nk57Zh.OwWtzHXTQhgBbaRhS4LIitsC",
    avatar:
      "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?ixlib=rb-4.0.3&amp;amp;ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8cGVyc29ufGVufDB8fDB8fA%3D%3D&amp;amp;w=1000&amp;amp;q=80",
  },
  {
    username: "DaBom",
    password: "$2b$10$h036pK1tWvpYRB3Evbq9j.nk57Zh.OwWtzHXTQhgBbaRhS4LIitsC",
    email: "dabom@dabom.com",
    avatar:
      "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?ixlib=rb-4.0.3&amp;amp;ixid=MnwxMjA3fDB8MHxzZWFyY2h8MzR8fHBlcnNvbnxlbnwwfHwwfHw%3D&amp;amp;w=1000&amp;amp;q=80",
  },
  {
    username: "lastcaique",
    email: "lastcaique@lastcaique.com",
    password: "$2b$10$h036pK1tWvpYRB3Evbq9j.nk57Zh.OwWtzHXTQhgBbaRhS4LIitsC",
    avatar:
      "https://st2.depositphotos.com/3143277/8644/i/600/depositphotos_86446164-stock-photo-business-man-in-office.jpg",
  },
];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to make the magic happen we will use &lt;code&gt;process.argv&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I personally name the file for my seeder/clearer &lt;code&gt;seed.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's now get to work:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We require the mock data we will use, along with mongoose, dotenv, and the Models.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { mockUsers } = require("../db/mock_data");
const mongoose = require("mongoose");
require("dotenv").config();
const { User, Post } = require("../models/models");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2- Store a connection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const connection = async () =&amp;gt; {
  mongoose.set("strictQuery", false);
  await mongoose
    .connect(process.env.DB_URI, { useNewUrlParser: true })
    .then(() =&amp;gt; console.log("DB READY TO SEED"))
    .catch((err) =&amp;gt; console.log(err));
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3- Now we create our first function, in my case is to seed. We call the connection function, and simply CREATE, exiting the process when done:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const seedDB = async () =&amp;gt; {
  await connection();
  await User.create(mockUsers)
    .then(() =&amp;gt; console.log("Users seeded"))
    .catch((err) =&amp;gt; console.log(err));

  process.exit();
};

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

&lt;/div&gt;



&lt;p&gt;4- Nothing new (hopefully) up to this point... so let's create another function that will clear the DB:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const clearDB = async () =&amp;gt; {
  await connection();
  await User.deleteMany()
    .then(() =&amp;gt; console.log("Users deleted"))
    .catch((err) =&amp;gt; console.log(err));

  process.exit();
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5- Finally, &lt;code&gt;argv&lt;/code&gt; will handle calling those functions, feel free to console.log it at this point, and run the file: &lt;code&gt;node seed.js&lt;/code&gt;&lt;br&gt;
 You will get an array with paths for index 0 and 1. BUT, if you add a 'flag', it will be the index 2:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;node seed.js --my_flag&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This log will have the flag as &lt;code&gt;process.argv[2]&lt;/code&gt;, allowing us to write scripts on &lt;code&gt;package.json&lt;/code&gt; to seed and clear:&lt;/p&gt;

&lt;p&gt;PACKAGE.JSON:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "scripts": {
    "start": "NODE_ENV=production node server/index.js",
    "dev": "nodemon server/index.js",
    "seedDB": "node server/db/seed.js --seedDB",
    "clearDB": "node server/db/seed.js --clearDB"
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally: based on the flag we will call the functions we created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (process.argv[2] === "--seedDB") {
  seedDB();
} else if (process.argv[2] === "--clearDB") {
  clearDB();
}

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

&lt;/div&gt;



&lt;p&gt;And DONE! Use the scripts to seed and clear anytime you need =)&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>mongoose</category>
      <category>database</category>
      <category>mern</category>
    </item>
    <item>
      <title>React is just JavaScript</title>
      <dc:creator>Aryse Gabrielle Pagano</dc:creator>
      <pubDate>Fri, 11 Nov 2022 19:42:51 +0000</pubDate>
      <link>https://dev.to/medic1111/react-is-just-javascript-11mj</link>
      <guid>https://dev.to/medic1111/react-is-just-javascript-11mj</guid>
      <description>&lt;p&gt;Not sure I would personally agree with that. If you ask my opinion, React is not JUST JavaScript but rather a whole bunch of it that I don't have to write. &lt;/p&gt;

&lt;p&gt;I don't know about you, but when I first started learning JavaScript one commonly used exercise (DOM and DOM manipulation) was to create a page entirely with Javascript. &lt;/p&gt;

&lt;p&gt;That required Imperative Programming, where you write line by line the steps required for something to happen.&lt;/p&gt;

&lt;p&gt;Because this post does not intend to dive deep in the rabbit hole, here's a simple and easily readable example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const body = document.getElementById("body");
const h1 = document.createElement("h1");
h1.innerText = "This is my h1";
body.append(h1);

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

&lt;/div&gt;



&lt;p&gt;What you see up there is just JavaScript. &lt;br&gt;
Now let's try to accomplish the same thing with React, which works in a declarative manner:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const HeadEl = ()=&amp;gt; &amp;lt;h1&amp;gt;This is my h1&amp;lt;/h1&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What you see up there, that looks like HTML is JSX (JavaScript XML) which kinda looks like HTML so we can be happy, and then gets compiled via BABEL to something that would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*#__PURE__*/React.createElement("h1", null, "This is my h1");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we were to be curious and &lt;code&gt;console.log(React.createElement)&lt;/code&gt; here's a little something from what we get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function createElementWithValidation(type, props, children) {
  var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
  // succeed and there will likely be errors in render.

  if (!validType) {
    var info = '';

    if (type === undefined || typeof type === 'object' &amp;amp;&amp;amp; type !== null &amp;amp;&amp;amp; Object.keys(type).length === 0) {
      info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
    }

    var sourceInfo = getSourceInfoErrorAddendumForProps(props);

    if (sourceInfo) {
      info += sourceInfo;
    } else {
      info += getDeclarationErrorAddendum();
    }

    var typeString;

    if (type === null) {
      typeString = 'null';
    } else if (isArray(type)) {
      typeString = 'array';
    } else if (type !== undefined &amp;amp;&amp;amp; type.$$typeof === REACT_ELEMENT_TYPE) {
      typeString = "&amp;lt;" + (getComponentNameFromType(type.type) || 'Unknown') + " /&amp;gt;";
      info = ' Did you accidentally export a JSX literal instead of a component?';
    } else {
      typeString = typeof type;
    }

    {
      error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
    }
  }

  var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
  // TODO: Drop this when these are no longer allowed as the type argument.

  if (element == null) {
    return element;
  } // Skip key warning if the type isn't valid since our key validation logic
  // doesn't expect a non-string/function type and can throw confusing errors.
  // We don't want exception behavior to differ between dev and prod.
  // (Rendering will throw with a helpful message and as soon as the type is
  // fixed, the key warnings will appear.)


  if (validType) {
    for (var i = 2; i &amp;lt; arguments.length; i++) {
      validateChildKeys(arguments[i], type);
    }
  }

  if (type === REACT_FRAGMENT_TYPE) {
    validateFragmentProps(element);
  } else {
    validatePropTypes(element);
  }

  return element;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All of that is what? Javascript, I agree. But to reduce this entire process into "It's just JavaScript" shows a little bit of lack understanding the very foundation of React, especially if that's all you have to offer when the question pops in a job interview. &lt;br&gt;
Hopefully I got you curious enough to go do some research and have a better understanding about this whole bunch of JavaScript you don't have to write. =)&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>selftaught</category>
    </item>
    <item>
      <title>Project based tutorial caution</title>
      <dc:creator>Aryse Gabrielle Pagano</dc:creator>
      <pubDate>Thu, 10 Nov 2022 14:53:21 +0000</pubDate>
      <link>https://dev.to/medic1111/project-based-tutorial-caution-1n5f</link>
      <guid>https://dev.to/medic1111/project-based-tutorial-caution-1n5f</guid>
      <description>&lt;p&gt;Being self-taught, it didn't take me long in my journey to end up exposed to a project-based tutorial. Regardless of the fact that some are extremely high quality, I almost immediately realized that the tutorial is only as good as your approach to it. &lt;br&gt;
Once I engaged in the community (which took me longer than it should have), I was able to confirm what before was a personal realization. Project based tutorials can HURT just as much as it could potentially help.&lt;br&gt;
Coming from a background of education and emergency medical services, I know very well that digesting information and knowing the "why" rather than the "how" is precisely the difference between being competent vs being capable.&lt;br&gt;
Tired of seeing some good mates with amazing portfolios struggling to code real time has led me to write this post. Enough with the copy and paste. You're wasting what is likely good material by taking the wrong approach. &lt;br&gt;
Here's my humble advice. When watching tutorials (especially project based) try your best to learn the concept, rather than "code-along" as its usually advised.&lt;br&gt;
Coding along doesn't have to mean "copy line by line". As a matter of fact, don't even code the SAME project. Come up with your own project that utilizes the same concepts and as you progress through the tutorial, implement the concepts learned.&lt;br&gt;
That will ensure, that you're not memorizing the project, but rather digesting the information being given, and reenforcing the knowledge by true application. &lt;br&gt;
That is how you increase acquired knowledge and is then able to reproduce the skills learned in any scenario. Example: If watching a tutorial on how to fetch data from a particular API, at the end of the tutorial you should be able to feel relatively comfortable with fetching data from ANY API. &lt;br&gt;
To conclude, therefore, project-based tutorials are simply tools. The final outcome of using a tool comes with your decision on how to use it.&lt;br&gt;
Good luck on your journey &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>selftaught</category>
      <category>tutorial</category>
      <category>community</category>
    </item>
  </channel>
</rss>
