<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: redeemefy</title>
    <description>The latest articles on Forem by redeemefy (@redeemefy).</description>
    <link>https://forem.com/redeemefy</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%2F212843%2F4a71ac23-b2da-4ab5-b81c-035fea3927e8.png</url>
      <title>Forem: redeemefy</title>
      <link>https://forem.com/redeemefy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/redeemefy"/>
    <language>en</language>
    <item>
      <title>MongoDB Setup With Docker</title>
      <dc:creator>redeemefy</dc:creator>
      <pubDate>Sun, 14 Mar 2021 21:52:47 +0000</pubDate>
      <link>https://forem.com/redeemefy/mongodb-setup-with-docker-106i</link>
      <guid>https://forem.com/redeemefy/mongodb-setup-with-docker-106i</guid>
      <description>&lt;p&gt;I'm not in the habit of writing my findings or steps when solving a problem. I am now making myself documenting as much as I can even though the solution is simple. I'm doing it since I have found myself searching the internet for things I worked on before but are not day-to-day tasks. I'm hoping on documenting things often enough that I can find them myself and potentially someone else can benefit from it.&lt;/p&gt;

&lt;p&gt;If you are like me, you don't like to install apps/tools on your machine just to try out an idea. Also, the truth goes when you are developing. You might want to keep your dev and prod environments the same throughout the SDLCs for avoiding bugs and/or problems. What we are actually trying to avoid is the famous phrase "It works in my computer...". Thank you, Docker, that you help us to avoid precisely that.&lt;/p&gt;

&lt;p&gt;Let us enable MongoDB in our machine with Docker.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;mkdir ~/docker-data &amp;amp;&amp;amp; mkdir ~/docker-data/mongodb&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docker run --name mongodb -v ~/docker-data/mongodb:/data/db -p 27017:27017 -d mongo&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first command creates a directory for mounting a volume where your data can be persisted, when you resume development the next day your data would be there. You can choose a different location though. The second command creates/downloads your image, exposes a port, mounts the volume, and starts the container.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;docker ps&lt;/code&gt; to see running containers&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docker ps --all&lt;/code&gt; to see all containers&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docker stop mongodb&lt;/code&gt; to stop the mongodb container&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docker start mongodb&lt;/code&gt; to start the mongodb container&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>docker</category>
      <category>mongodb</category>
    </item>
    <item>
      <title>Why Software Engineering is not regulated?</title>
      <dc:creator>redeemefy</dc:creator>
      <pubDate>Mon, 30 Dec 2019 03:35:38 +0000</pubDate>
      <link>https://forem.com/redeemefy/why-we-all-are-called-engineers-3l3d</link>
      <guid>https://forem.com/redeemefy/why-we-all-are-called-engineers-3l3d</guid>
      <description>&lt;p&gt;&lt;em&gt;I want to start by saying that my intention is not to denigrate or diminish people's effort or profession. This post is to stimulate discussion among the community.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I have been reading &lt;a href="https://en.wikipedia.org/wiki/Engineer"&gt;here&lt;/a&gt; about the engineering discipline regardless of the domain in which it is getting deployed and it sparked several questions. It appears to me that the discipline of Software Engineer as we know it today is not performed as other engineering does in other domains such as electrical, mechanical, civil, etc, and I'm wondering why might be the case.&lt;/p&gt;

&lt;p&gt;I want to number the points I see are similar but in practice are different:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Education&lt;/li&gt;
&lt;li&gt;License&lt;/li&gt;
&lt;li&gt;Research&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Education: I want to mention education not in the sense that people need a formal education to write software and have a job, but in other engineering disciplines, education is required to the point that you are not allowed to perform the discipline without education. Nowadays a computer science or software engineer degree is not required to land a job.&lt;/p&gt;

&lt;p&gt;Let's say that I learned everything needed to be a civil engineer on Coursera, Edx, or any other free MOOC. Not only I learned it, but it is also possible that I take the state license exam and pass it. Why am I not allowed to perform as a civil engineer and build a bridge or a skyscraper? I'm going to answer my question on my ignorance. I think it is because I didn't get a formal education that is well rounded with all the courses needed, the mentorship that is required in many countries and the license to be responsible for the outcome of each decision I make. Decisions that are not light since the lives of many rely on my design and decisions for that construction.&lt;/p&gt;

&lt;p&gt;So I have a few questions on the topic of education that I don't have the answer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Where we draw the line?&lt;/li&gt;
&lt;li&gt;Do you trust the ML algorithm that denies your loan?&lt;/li&gt;
&lt;li&gt;Do you trust the software that is written in IoT devices?&lt;/li&gt;
&lt;li&gt;... thinking about critical software, that puts someone on the jail, or schedules someone for surgery, or even worse, you do have the disease and the software said no you don't.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;License: All other disciplines of engineering requires a state license to perform as an engineer. I think that this is a measure to protect/ensure the quality of the work and the safety of the people. I have heard of some edge cases where you don't need a license but in general, you do. However, in the software industry, you don't need anything at all. Since software applications are everywhere and in everything...&lt;/p&gt;

&lt;p&gt;Here next to me is my wife telling me about a nursing license test that she would take if she decides to go to nursing school. I didn't know that a nurse has to take a licensing exam.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Do you allow a self-taught nurse to take care of you in the hospital?&lt;/li&gt;
&lt;li&gt;Do you think that the software industry could get out of control?&lt;/li&gt;
&lt;li&gt;Do you think that we need to put some control like a state license?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Research: My observation with research is that in the design face of any project, the research analysis is done before you can proceed with the project, in Software Engineer we don't. We do have research done at the academic level where innovation is taking place or in big tech companies since they can afford to have their R&amp;amp;D department.&lt;/p&gt;

&lt;p&gt;This is how normally goes...&lt;br&gt;
Hey, we have a green project and we need to come up with a POC. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;That is great, I have been waiting for a greenfield project so I can learn Svelte. Can we use it in this project?&lt;/li&gt;
&lt;li&gt;We should do a microservice architecture... Dude, this is a POC.&lt;/li&gt;
&lt;li&gt;And the list goes on...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This scenario doesn't look like research to me.&lt;/p&gt;

&lt;p&gt;I think it would be beneficial for the industry to have separation of duties in their titles. That way you can tell who is doing what. For instance...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Software Architects - need a license&lt;/li&gt;
&lt;li&gt;Software Engineers - need a license&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Software Programmers - don't need a license&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What are your thoughts on this topic?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do you think that the software industry needs to start to put some guard rails?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>healthydebate</category>
    </item>
    <item>
      <title>How to test throw with Jest</title>
      <dc:creator>redeemefy</dc:creator>
      <pubDate>Sun, 15 Dec 2019 00:00:00 +0000</pubDate>
      <link>https://forem.com/redeemefy/how-to-test-throw-with-jest-3bde</link>
      <guid>https://forem.com/redeemefy/how-to-test-throw-with-jest-3bde</guid>
      <description>&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I had this post in my personal blog but decided to try to link my RSS feed here and see how it goes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Assumptions&lt;/li&gt;
&lt;li&gt;Resources&lt;/li&gt;
&lt;li&gt;Scenario&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Assumptions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You know how to install and use Jest&lt;/li&gt;
&lt;li&gt;You know how to develop programs in JavaScript&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;The &lt;a href="https://jestjs.io/docs/en/expect#tothrowerror"&gt;Jest&lt;/a&gt; documentation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Scenario
&lt;/h2&gt;

&lt;p&gt;Currently, at work, there is an effort to refactor a codebase to make it more maintainable and scalable. The JavaScript code is running in an unusual environment that is not a browser nither a node server. I’m extracting common functionality into a utility library and writing unit-test for all functions.&lt;br&gt;&lt;br&gt;
I have used Jest before for frontend code but this is the first time using Jest for pure functions. Our use case is particular and we need to carefully choose which functions are going to throw/return an error.&lt;br&gt;&lt;br&gt;
When I start writing unit-test for a function that returns an error I started having issues with it. Let consider a sample function and let’s say that I’m going to throw an error if any of the parameters are null.&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;addTwoNumbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;num1IsNull&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;num2IsNull&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;num2&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&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;num1IsNull&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;num2IsNull&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;One of the parameters is not a number&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="c1"&gt;// continue your code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addTwoNumbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path/to/addTwoNumbers&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;addTwoNumbers&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;should throw error if num1 is null&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// This expect wont error out but it wont pass either.&lt;/span&gt;
        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;addTwoNumbers&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;One of the parameters is not a number&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;The correct way to test this is not by expecting the string that comes back but rather that the function did &lt;code&gt;throw&lt;/code&gt;. Let’s consider the following test. It will be slightly different from the above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addTwoNumbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path/to/addTwoNumbers&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;addTwoNumbers&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;should throw error if num1 is null&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Notice that expect takes a function that return the function under test. &lt;/span&gt;
        &lt;span class="c1"&gt;// If I pass (3,5) the test will faild.&lt;/span&gt;
        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;addTwoNumbers&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nx"&gt;toThrow&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;



</description>
    </item>
    <item>
      <title>Adding Dummy Data to Firebase</title>
      <dc:creator>redeemefy</dc:creator>
      <pubDate>Tue, 29 Aug 2017 00:00:00 +0000</pubDate>
      <link>https://forem.com/redeemefy/adding-dummy-data-to-firebase-70k</link>
      <guid>https://forem.com/redeemefy/adding-dummy-data-to-firebase-70k</guid>
      <description>&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; &lt;br&gt;
This post was originally posted in my &lt;a href="//gilbertodiaz.com"&gt;personal blog&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Table of contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Table of contents&lt;/li&gt;
&lt;li&gt;Assumptions&lt;/li&gt;
&lt;li&gt;Scope&lt;/li&gt;
&lt;li&gt;Resources&lt;/li&gt;
&lt;li&gt;How to get the data?&lt;/li&gt;
&lt;li&gt;Pushing data to Firebase&lt;/li&gt;
&lt;li&gt;Creating data with relationships&lt;/li&gt;
&lt;li&gt;Pushing events node to Firebase&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Assumptions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You are developing an application utilizing firebase.&lt;/li&gt;
&lt;li&gt;You need a fast and easy way to populate Firebase with dummy data.&lt;/li&gt;
&lt;li&gt;You want to add another tool to your toolbox.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Scope
&lt;/h2&gt;

&lt;p&gt;There are times that you have an idea and you just started coding it out. It’s just an idea so you don’t want to write a test suite or to set up an entire development environment. After a couple of hours, you realized that your idea is looking good. Now you need some data to shape some UI and to get some functionality going on. This short tutorial will show you how to get that data quickly to firebase.&lt;/p&gt;
&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://www.mockaroo.com/" rel="noopener noreferrer"&gt;mockaroo.com&lt;/a&gt; website has a short tutorial on how to use the app. You can also find a &lt;a href="https://www.youtube.com/watch?v=XATDlwG1azU&amp;amp;index=1&amp;amp;list=PLKMZcxOsC3u0Y-4CHg5SDpVjTcrvGttTt" rel="noopener noreferrer"&gt;Mockaroo video tutorials&lt;/a&gt; here.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to get the data?
&lt;/h2&gt;

&lt;p&gt;Click the link &lt;code&gt;mockaroo.com&lt;/code&gt; in the resources section above. Once you get to the page you will see a screen like the following…&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%2Fgilbertodiaz.com%2Fimages%2Fmockroo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgilbertodiaz.com%2Fimages%2Fmockroo.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Modify the fields as needed. In the &lt;code&gt;#Row&lt;/code&gt; type the number of records you need; I believe that the amount is limit to 1000 or less, in my case I choose 100. In the &lt;code&gt;Format&lt;/code&gt; pulldown choose Json and click Download Data.&lt;/p&gt;
&lt;h2&gt;
  
  
  Pushing data to Firebase
&lt;/h2&gt;

&lt;p&gt;If you don’t care about having the auto-generated firebase ids in your data, you can just import the file into the desired node in Firebase. You will have id’s from 0 to whatever number of records you choose. I don’t know about you but I like to simulate the data as close as possible, including the firebase id. You can accomplish this by pushing the JSON file utilizing a short javascript script. The following snippet will push the data to a node called &lt;code&gt;users&lt;/code&gt; and firebase will auto-generate ids for us.&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;var&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your api key goes here&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;authDomain&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your_app.firebaseapp.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;databaseURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://your_app.firebaseio.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;projectId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your_app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;storageBucket&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your_app.appspot.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;messagingSenderId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1234567890&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;initializeApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;database&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;users/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ajax&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./MOCK_DATA.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;done&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="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 data in the Firebase console will looks like this…&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%2Fgilbertodiaz.com%2Fimages%2Fusers_node.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgilbertodiaz.com%2Fimages%2Fusers_node.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWESOME!!! now I have 100 users with auto generated firebase id’s.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating data with relationships
&lt;/h2&gt;

&lt;p&gt;There are times where you need some sort of relationship between nodes. To accomplish this you need to push your data to Firebase, export the data that you just push to Firebase and upload it to mockaroo. Sounds a little confusing but don’t worry I’m going to walk you through the process.&lt;/p&gt;

&lt;p&gt;We are going to utilize the same &lt;code&gt;json&lt;/code&gt; files with 100 users but we are going to slightly change the way we push the data to Firebase. Consider the following &lt;code&gt;javascript&lt;/code&gt; script…&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;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;database&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ajax&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../users.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;done&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newPostKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;getKey&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;uid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newPostKey&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;child&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newPostKey&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="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;First, we need to create a reference to the user’s node. If the node doesn’t exist in Firebase it will be created for you on the first push so you don’t need to create yourself. As the previous script, I’m utilizing &lt;code&gt;jQuery&lt;/code&gt; but you can use whatever way you are comfortable with. After reading the file I’m iterating over each record. On each iteration I’m asking Firebase to create a new entry but without the data… &lt;code&gt;let newPostKey = users.push().getKey();&lt;/code&gt;. What happened with this line is that Firebase creates a new entry to the node, returns the key, and is waiting for the data to close the transaction. In the next line… &lt;code&gt;item.uid = newPostKey;&lt;/code&gt; I’m taking that &lt;code&gt;newPostKey&lt;/code&gt; which is the ugly_id that Firebase creates for each entry, and adding it as a parameter inside the node as uid. Finally, I’m posting the data to the desired node. Now my data looks like the following…&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%2Fgilbertodiaz.com%2Fimages%2Fuser_with_uid.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgilbertodiaz.com%2Fimages%2Fuser_with_uid.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we have the &lt;code&gt;uid&lt;/code&gt; as a value for each user. This is useful since we have easy access to the value. Next, we need to export the users node from Firebase. Once you download the file, try to find a &lt;code&gt;json&lt;/code&gt; to &lt;code&gt;csv&lt;/code&gt; converter online. Once you have your data in &lt;code&gt;csv&lt;/code&gt; format go to &lt;a href="https://www.mockaroo.com/" rel="noopener noreferrer"&gt;mockaroo.com&lt;/a&gt; and click on &lt;code&gt;DATASETS&lt;/code&gt; at the navbar. Click on &lt;code&gt;Upload a New Dataset&lt;/code&gt;, navigate your system to find your &lt;code&gt;csv&lt;/code&gt; file. Now click on &lt;code&gt;SCHEMAS&lt;/code&gt; on the navbar and create a new schema, in my case I’m going to create a schema called events. I want my uid value from the &lt;code&gt;users&lt;/code&gt; node on each event entry, to do that I need to import the data set to the new schema. In the Type column select &lt;code&gt;Dataset Column&lt;/code&gt;. Next to the Type is Options, select the data set and next to Options is the field you want to use. What is going to happen is that on each record mockaroo creates it will randomly select an uid for each record. My new schema looks like this…&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%2Fgilbertodiaz.com%2Fimages%2Fevent_with_uid.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgilbertodiaz.com%2Fimages%2Fevent_with_uid.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To download the data you need to repeat the same process as before. Select the amount records you need, &lt;code&gt;json&lt;/code&gt; format, and click download. You can also click preview before you download to see how your data will look like.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pushing events node to Firebase
&lt;/h2&gt;

&lt;p&gt;To push your new data to Firebase is the same process as before just make sure to have a reference to the correct node before you push your data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;events&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;database&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;events&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ajax&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../events.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;done&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newPostKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;getKey&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;uid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newPostKey&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;child&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newPostKey&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="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 event’s node looks like this…&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%2Fgilbertodiaz.com%2Fimages%2Fevent_node_with_uid.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgilbertodiaz.com%2Fimages%2Fevent_node_with_uid.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NICE!!! Now I have a &lt;code&gt;users&lt;/code&gt; node with the &lt;code&gt;ugly_id&lt;/code&gt; inside each entry as the &lt;code&gt;uid&lt;/code&gt; and I have an &lt;code&gt;events&lt;/code&gt; node with the user’s name and &lt;code&gt;uid&lt;/code&gt; on each event and randomly create by mockaroo. This is really handy for fast prototyping and have some data in the DOM.&lt;/p&gt;

&lt;p&gt;At the time I’m writing this short tutorial, I’m part of the Nashville Software School community in Nashville, TN, and I thought that this would be helpful for students building their capstones. Please share with your fellow students if you find it helpful.&lt;/p&gt;

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