<?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: Keely</title>
    <description>The latest articles on DEV Community by Keely (@spacerambler).</description>
    <link>https://dev.to/spacerambler</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%2F648401%2F2980f54b-7755-4e60-a93b-1b851598ec9a.jpeg</url>
      <title>DEV Community: Keely</title>
      <link>https://dev.to/spacerambler</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/spacerambler"/>
    <language>en</language>
    <item>
      <title>Blog with Node, MongoDB, and React</title>
      <dc:creator>Keely</dc:creator>
      <pubDate>Wed, 12 Jan 2022 04:46:57 +0000</pubDate>
      <link>https://dev.to/spacerambler/blog-with-node-mongodb-and-react-4l2o</link>
      <guid>https://dev.to/spacerambler/blog-with-node-mongodb-and-react-4l2o</guid>
      <description>&lt;p&gt;&lt;strong&gt;1.11.22&lt;/strong&gt;&lt;br&gt;
It's been awhile since I've coded... yay post-bootcamp burnout. I'm starting my 100 Days of Code challenge to rework the bootcamp assignments using React. &lt;/p&gt;

&lt;p&gt;I read a Twitter thread (which I've lost) but it got me motivated to get back to my code practice. I wrote down "backend headless cms - node, mongoDB, and react."&lt;/p&gt;

&lt;p&gt;So, I'll be researching headless CMS which at initial glance looks like a hot topic right now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a headless cms?&lt;/strong&gt; From &lt;a href="https://www.contentful.com/r/knowledgebase/what-is-headless-cms/"&gt;Contentful&lt;/a&gt;, "A headless CMS is any type of back-end content management system where the content repository "body" is separated or decoupled from the presentation layer "head." Content that is housed in a headless CMS is delivered via APIs for seamless display across different devices... structuring content so that it can be reused across different platforms and channels."&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;Before I go too far down a rabbit hole... I need to get re-familiar with how to set up an app. &lt;/p&gt;

&lt;p&gt;While I go through my notes, I guess the real start of this project is figuring out my objective and a design draft.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;I enjoy spending my time reading and writing about a range of topics, recent adventures, and new findings. I want to build a CMS blog where I can publish blog posts, short stories, notes, and life updates and allow of comments on posts... creating a "Digital Oasis".&lt;/p&gt;

&lt;h3&gt;
  
  
  User Story
&lt;/h3&gt;

&lt;p&gt;As a developer who writes&lt;br&gt;
I want a CMS-style blog site&lt;br&gt;
So that I can publish my content&lt;/p&gt;

&lt;h3&gt;
  
  
  MVP
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Home&lt;/li&gt;
&lt;li&gt;Blog Page&lt;/li&gt;
&lt;li&gt;Blog Post&lt;/li&gt;
&lt;li&gt;Login&lt;/li&gt;
&lt;li&gt;Blog Entry&lt;/li&gt;
&lt;li&gt;Logged-In Blog Post State&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Road Map
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;In no particular order...&lt;/em&gt;&lt;br&gt;
Theming/CSS, Comments, Newsletter Signup, Content Sections, Calendar&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Edit: I started this project with a massive starter pack that we used during the final project of bootcamp. I ended up scrapping most of it and rebuilding from point zero because I needed to work my way back up.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.17.22&lt;/strong&gt;&lt;br&gt;
I'm back... a week later, still going strong in the green. I've done a few things. Set up bootstrap and got a few components rendering with React. &lt;/p&gt;

&lt;p&gt;Here are my next steps for this week:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Seed the database&lt;/li&gt;
&lt;li&gt;Pull content from the database into the blog post &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;1.22.22&lt;/strong&gt;&lt;br&gt;
So, I still have not seeded the database but I have reworked my server side folders and have done the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set up server&lt;/li&gt;
&lt;li&gt;Create env file&lt;/li&gt;
&lt;li&gt;Finished setting up models&lt;/li&gt;
&lt;li&gt;Started routes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Right now I just have the scaffolding for the routes but that will be my next couple of days. &lt;/p&gt;

&lt;p&gt;Overall thoughts right now: I definitely learned a lot during coding bootcamp and it's all coming back piece by piece. The reason why I got into coding was because I like the puzzle aspect. It's really nice to get to put this together without the breakneck speed and pressure of the bootcamp.&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>react</category>
    </item>
    <item>
      <title>Express + Mongo Simplified</title>
      <dc:creator>Keely</dc:creator>
      <pubDate>Thu, 02 Sep 2021 23:48:34 +0000</pubDate>
      <link>https://dev.to/spacerambler/express-mongo-simplified-1eki</link>
      <guid>https://dev.to/spacerambler/express-mongo-simplified-1eki</guid>
      <description>&lt;p&gt;&lt;em&gt;More notes I was taking in class to capture the steps to use Mongo DB and express routes... WIP&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;File List: *&lt;/em&gt;&lt;br&gt;
package.json&lt;br&gt;
.env&lt;br&gt;
config.js&lt;br&gt;
index.js&lt;br&gt;
routes.js&lt;br&gt;
controller.js&lt;/p&gt;

&lt;p&gt;Getting started, we are using the zoo database.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Because we have everything installed, Mongo is always running in the background&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  package.json
&lt;/h2&gt;

&lt;p&gt;Will need to add the following: &lt;br&gt;
*express&lt;br&gt;
*mongodb&lt;br&gt;
*dotenv&lt;/p&gt;
&lt;h2&gt;
  
  
  .env
&lt;/h2&gt;

&lt;p&gt;Copy string from mongosh and add to this file.&lt;br&gt;
Also add the port number here.&lt;/p&gt;
&lt;h2&gt;
  
  
  config.js
&lt;/h2&gt;

&lt;p&gt;Use this file to connect the env with the rest of the application, export&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import dot env from 'dotenv';
dotenv.config();
export default {
port: process.env.PORT || 3000,
db: proces.env.DB_CLIENT_URL
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the port number is not provided in env file, it will default to 3000 (aka short circuit pattern).&lt;/p&gt;

&lt;p&gt;Next, import config into index.js&lt;/p&gt;

&lt;h2&gt;
  
  
  loader.js
&lt;/h2&gt;

&lt;p&gt;Use this to set up the mongo client &amp;amp; export it out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { MongoClient } from "mongodb";
import config from "./config.js";

const client = new MongoClient(config.db);

client
  .connect()
  .then(() =&amp;gt; {
    console.info("Connected to MongoDB");
  })
  .catch((err) =&amp;gt; {
    console.error("Error starting MongoDB Client");
    process.exit(1);
    // using "1" as exit code because it's not a graceful exit
    // using "0" as exit code because it's a graceful exit
  });

process.on("SIGINT", () =&amp;gt; {
  client.close().then(() =&amp;gt; {
    console.info("MongoDB connection closed");
    process.exit(0);
  });
});

export default client;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  index.js
&lt;/h2&gt;

&lt;p&gt;*import&lt;br&gt;
*declare&lt;br&gt;
*get path, call back&lt;br&gt;
*listen&lt;br&gt;
... everything between localhost:3000/ and localhost:3000/api&lt;/p&gt;
&lt;h2&gt;
  
  
  routes.js
&lt;/h2&gt;

&lt;p&gt;*import &lt;br&gt;
*declare&lt;br&gt;
*get path, call back&lt;br&gt;
*use&lt;/p&gt;
&lt;h2&gt;
  
  
  controller.js
&lt;/h2&gt;

&lt;p&gt;Creating a method that connects to the database collection we want to use... then import it into routes.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const controller = {
async index()
 {
const animals = await client.db("zoo")
.collection("animals")
.find()
.toArray();
return animals;
}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;.find creates a cursor that allows us to go into the array and do stuff like filter or sort. &lt;br&gt;
We can pass in a parameter into the index() that will allow us to use the fields in the routes... will need to interpolate using a bracket when calling it. &lt;/p&gt;
&lt;h2&gt;
  
  
  routes.js
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;create a route that gets all the animals&lt;/em&gt;&lt;br&gt;
&lt;a href="http://localhost:3000/animals"&gt;http://localhost:3000/animals&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import animalsController from "./controller.js"
router.get("/animals", async (_, res)=&amp;gt;{
const animals = await animalsController.index();
res.json(animals);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Create a route that sorts by a field&lt;/em&gt;&lt;br&gt;
&lt;a href="http://localhost:3000/animals?sort=class"&gt;http://localhost:3000/animals?sort=class&lt;/a&gt;&lt;br&gt;
In the route we will add the parameters into the path and then we'll need to interpolate that parameter in the controller.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const controller = {
async index(sortBy)
 {
const animals = await client.db("zoo")
.collection("animals")
.find()
.sort({ name: 1 })
.toArray();
return animals;
}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then we'll need to update the router to include the sort parameter&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import animalsController from "./controller.js"
router.get("/animals", async (req, res)=&amp;gt;{
const animals = await animalsController.index(req.query.sort);
res.json(animals);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CRUD Routes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;FROM HERE WE STARTED USING A NEW DATABASE FOR A NOTE TAKER APP&lt;/strong&gt;&lt;br&gt;
Mongo DB is going to create a new collection dynamically. Won't need to set anything up beforehand since we already have everything connected in the .env.&lt;/p&gt;

&lt;p&gt;First, need to add json middleware to index.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import morgan from "morgan"
app.use(morgan("dev"))
app.use(express.json());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Morgan logs the routes in node&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Mount the routes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import apiRouter from "./router.js"
app.use("/api", apiRouter)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  POST
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Starting the post route to create a new note&lt;/em&gt;&lt;br&gt;
&lt;a href="http://localhost:3000/api/"&gt;http://localhost:3000/api/&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;router.post("/", (req, res)=&amp;gt;{
res.json(req.body);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Practicing iterative coding...&lt;br&gt;
Go back to the controller.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import client from "./loader.js";
export default {
 create(newNote) {
return client.db("noteTaker").collection("notes").insertOne(newNote);
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then add controller to routes file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import noteController from "./controller.js"
router.post("/", (req, res)=&amp;gt;{
const newNote = await noteController.create(req.body);
res.json(req.body);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add in try/catch for errors in the route&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;router.post("/notes", async (req, res)=&amp;gt;{
try {
const newNote = await noteController.create(req.body);
res.json(req.body);
} catch (error) {
rest.status(400).json(error.message)
}
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  GET
&lt;/h3&gt;

&lt;p&gt;Prints all the notes in the database.&lt;/p&gt;

&lt;p&gt;Starting with the routes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;router.get("/notes", async (req, res) =&amp;gt; {
try {
const notes = await noteController.index();
res.json(notes)
} catch (error) {
res.state(400).json(error.message)}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then add to the controller...&lt;br&gt;
This file is using the mongo db library of methods.&lt;br&gt;
&lt;strong&gt;Link to those methods&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import client from "./loader.js";
export default {
index() {
return notesConnection.find({}).toArray();
},
 create(newNote) {
return client.db("noteTaker").collection("notes").insertOne(newNote);
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  GET
&lt;/h3&gt;

&lt;p&gt;Print 1 note (instead of all the notes)&lt;br&gt;
In the controller we can use .findOne(id)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;show(id) {
return notesConnection.findOne(ObjectId(id));
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding to routes, we'll need to use a dynamic path. We'll also need to add in params&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;router.get("/notes/:id", async (req, res) =&amp;gt; {
try {
const note = await noteController.show(req.params.id);
res.json(note);
} catch(error) {
res.status(400).send(error);
}
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  DELETE
&lt;/h3&gt;

&lt;p&gt;Delete a note... going to skip the routes since this is a review.&lt;br&gt;
In the controller, we'll need to use .deleteOne and pass in the id as an object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;delete(id) {
 return notesConnection.deleteOne({ _id: ObjectId(id) });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>MVC file structure notes</title>
      <dc:creator>Keely</dc:creator>
      <pubDate>Fri, 06 Aug 2021 02:58:02 +0000</pubDate>
      <link>https://dev.to/spacerambler/wip-mvc-2ipp</link>
      <guid>https://dev.to/spacerambler/wip-mvc-2ipp</guid>
      <description>&lt;p&gt;Homework: Blog&lt;/p&gt;

&lt;h2&gt;
  
  
  New File Structure
&lt;/h2&gt;

&lt;p&gt;server.js &amp;gt; adding in many new packages that will need to be started to run all these files simultaneously &lt;/p&gt;

&lt;h3&gt;
  
  
  Controllers
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Replaces routes&lt;/em&gt;&lt;br&gt;
   index.js (similar, uses router object rather than app)&lt;br&gt;
   home-routes.js (Express code, addition is a snippet that connects the router to a view)&lt;br&gt;
   api &amp;gt; index.js, user-routes.js (ie. this is using Express to save login variables&lt;/p&gt;

&lt;h3&gt;
  
  
  Utils
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;new&lt;/em&gt;&lt;br&gt;
   helpers.js&lt;br&gt;
In this example, this is adding formatting and pulling in time and date. Separate middleware from routes. If a piece of code is used in multiple routes, can pull that out into it's own file that each route can tap into as needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Views
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;new&lt;/em&gt;&lt;br&gt;
Basically these files are creating html code that can pull in data from the database and are strung together using Express.&lt;br&gt;
Pages not nested in other folders here but they are using the file in the layout to complete the page. The partial files are components that are used on multiple pages.&lt;/p&gt;

&lt;h3&gt;
  
  
  Public
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;new&lt;/em&gt;&lt;br&gt;
"Static" code that the Views files pull from.&lt;br&gt;
   CSS&lt;br&gt;
   Images&lt;br&gt;
   JS &amp;gt; login.js, logout.js&lt;/p&gt;

&lt;p&gt;&lt;em&gt;no change&lt;/em&gt;&lt;br&gt;
Config &lt;br&gt;
db&lt;br&gt;
Models&lt;br&gt;
Seeds&lt;/p&gt;

&lt;p&gt;Documentation:&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/express-handlebars"&gt;https://www.npmjs.com/package/express-handlebars&lt;/a&gt; &amp;lt;&amp;lt; this is the one listed out in the dependencies of the package.json&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/express"&gt;https://www.npmjs.com/package/express&lt;/a&gt; &lt;/p&gt;

</description>
    </item>
    <item>
      <title>WIP =&gt; Making Sense of ORM Chaos</title>
      <dc:creator>Keely</dc:creator>
      <pubDate>Tue, 03 Aug 2021 23:11:24 +0000</pubDate>
      <link>https://dev.to/spacerambler/making-sense-of-orm-chaos-3l53</link>
      <guid>https://dev.to/spacerambler/making-sense-of-orm-chaos-3l53</guid>
      <description>&lt;p&gt;Getting lost in the sauce that is setting EVERYTHING up for ORM projects. &lt;/p&gt;

&lt;p&gt;Node.js is the language to build and talk to a server. Express is a framework to make that easier. Bootstrap is to CSS as Express is to Node.js.&lt;/p&gt;

&lt;p&gt;I'm working through setting up an ecommerce backend by modifying starter code and configuring a working Express.js API to use Sequelize to interact with a MySQL database. S&lt;/p&gt;

&lt;p&gt;So I'll need to do a few things in the set up.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Set Up
&lt;/h2&gt;

&lt;p&gt;Add npm files to package.json and update with name of project (include sequelize, express, dotenv, mysql2)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Look through the package json to see what's already been set up for commands to run - run seed, nodemon&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i sequelize
npm i express
npm i dotenv
npm i mysql2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;these were all included in the code provided in wustl&lt;/em&gt;&lt;br&gt;
Copy server file (express)&lt;br&gt;
Create connection folder and copy over connection.js file&lt;br&gt;
Create .env file and update db name for project&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Set up database&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql -u root -p
SOURCE schema.sql
quit
npm run seed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;run server&lt;/em&gt;&lt;br&gt;
&lt;code&gt;node server.js&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The Data
&lt;/h2&gt;

&lt;p&gt;When actually starting to code, we need to start by setting up the Models. But first, let's visualize the data by working our way back from Routes.&lt;/p&gt;

&lt;p&gt;In the database, each table will require it's own model and route. These are all brought together using "index.js" located in each folder. &lt;br&gt;
So the main route index pulls all the routes together under /api to be used in the server file. We are expected to get JSON back.&lt;/p&gt;

&lt;p&gt;[localhost:3002/api]&lt;/p&gt;

&lt;p&gt;The router folder index creates the paths for each individual route set up: /travellers, /locations, /trips.&lt;/p&gt;

&lt;p&gt;[localhost:3002/api/travellers]&lt;/p&gt;

&lt;p&gt;And then the Models index links together the individual models traveller, location, trip&lt;/p&gt;

&lt;p&gt;[localhost:3002/api/:traveller]&lt;/p&gt;
&lt;h3&gt;
  
  
  Seeds
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;We were provided with Seeds which gives us an example of each data table that should be created which can then help us build the models&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Models
&lt;/h3&gt;

&lt;p&gt;Set up Model folder and models&lt;br&gt;
Add references snippets to Models&lt;br&gt;
Create model index: Product, Category, Tag, ProductTag&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Define columns for each column (Add validation, include decimals)&lt;/li&gt;
&lt;li&gt;Extend Product model to set up fields and rules (&lt;strong&gt;need to figure out where this is used and then complete&lt;/strong&gt;) &lt;/li&gt;
&lt;li&gt;Finish model index &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Validation Scaffolding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user.init({id: {}, username:{type:, validate: {}},sequelize...});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Indexing Models
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;.hasOne&lt;/strong&gt;&lt;br&gt;
Define a Driver as having one License to create a foreign key in the license table. Also define the association starting with License. If driver is deleted, cascade also deleted the associated License.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Driver.hasOne(License, {
foreignKey: 'driver_id',
onDelete: 'CASCADE'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.belongsTo&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;License.belongsTo(Driver, {
foreignKey: 'driver_id',
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.hasMany&lt;/strong&gt;&lt;br&gt;
Define a Driver as having many Cars, thus creating a foreign key in the 'car' table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Driver.hasMany(Car, {
foreignKey: 'driver_id',
onDelete: 'CASCADE', });
Car.belongsTo(Driver, {
foreignKey: 'driver_id', });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.belongsToMany&lt;/strong&gt;&lt;br&gt;
Define the third table needed to store the foreign keys&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Location.belongsToMany(Traveller, {
through: {
model: Trip,
unique: false}, 
as: 'location_travellers'});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;How to test these... run the seeds through the database.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Routes
&lt;/h2&gt;

&lt;p&gt;Index has been set up for us: /categories, /products, /tags&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To Dos:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Category Routes &amp;amp; Insomnia set up&lt;/li&gt;
&lt;li&gt;Product Routes &amp;amp; Insomnia set up&lt;/li&gt;
&lt;li&gt;Tag Routes &amp;amp; Insomnia set up&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  GET
&lt;/h3&gt;

&lt;p&gt;The purpose of the GET route is to find all the data and return as json so we can then use that data in other areas/services (ie. all locations). Can also bring in filtered data (ie. a single location).&lt;/p&gt;

&lt;p&gt;Async Await scaffolding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;router.get('/', async (req, res) =&amp;gt; {try{}catch(err){}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I started to set up my first GET route in Insomnia to test, and ran into to do item in the body-parser. This is part of express middleware that needs to be configured.&lt;/p&gt;

&lt;h5&gt;
  
  
  Misc. Notes
&lt;/h5&gt;

&lt;p&gt;&lt;em&gt;What do the different status codes mean for each?&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Are we supposed to push to github with our .env file included?&lt;/strong&gt;&lt;br&gt;
add to .gitignore &amp;gt;&amp;gt; the name of that file is there so we don't need to worry about it in this project&lt;/p&gt;

&lt;p&gt;Documentation: &lt;br&gt;
&lt;a href="https://www.npmjs.com/package/sequelize"&gt;https://www.npmjs.com/package/sequelize&lt;/a&gt; &lt;br&gt;
&lt;a href="https://www.npmjs.com/package/express"&gt;https://www.npmjs.com/package/express&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/dotenv"&gt;https://www.npmjs.com/package/dotenv&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/mysql2"&gt;https://www.npmjs.com/package/mysql2&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Branching Out</title>
      <dc:creator>Keely</dc:creator>
      <pubDate>Sat, 12 Jun 2021 20:51:18 +0000</pubDate>
      <link>https://dev.to/spacerambler/branching-out-2bfl</link>
      <guid>https://dev.to/spacerambler/branching-out-2bfl</guid>
      <description>&lt;p&gt;&lt;em&gt;Mapping out the Git Branching steps for my first group development project &amp;amp; reflections on the bootcamp so far...&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Git Branching Steps
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;I wanted to capture a bit of the process -- how I understand it -- here to serve as a reference for me and my group as we start to memorize the steps for working together using Git Branches.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  In the designated Feature branch...
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;In the Github Project Kanban, move card from To Do to In progress&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git pull origin dev&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;code&gt;git switch -c [feature-name]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Make and save changes in VS Code&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git add -A&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git commit -m "Short description of update"&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git push origin [feature-name]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;In the Github Project Kanban, move card from In progress to Review&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Whoever did not push the code, reviews the changes. If approved, the PM pulls the request into the dev branch and deletes the feature branch. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Instructor's Tip:&lt;/strong&gt; Commit small incremental commits to avoid conflicts&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;But first... I had to get the repo onto my machine.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Cloning the repo and the initial commit
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Our assigned lead developer created new Repository &lt;/li&gt;
&lt;li&gt;I clicked the Code dropdown to copy the SSH link&lt;/li&gt;
&lt;li&gt;In Git Bash, &lt;code&gt;git clone [pasted SSH link]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Then, entered the directory with &lt;code&gt;cd [directory-name]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Switched to a new branch with &lt;code&gt;git checkout -b keely&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Made a small change to the html file using VSC&lt;/li&gt;
&lt;li&gt;Followed steps to add, commit, push change
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;git add -A&lt;br&gt;
git commit -m "Update HTML title in head"&lt;br&gt;
git push origin keely&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Instructor's Tip:&lt;/strong&gt; Instead of naming the branches as our own names, name the branches the features of our project&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Beginning Reflections
&lt;/h2&gt;

&lt;p&gt;7 weeks in this coding bootcamp... &lt;em&gt;sheesh!&lt;/em&gt; I knew it was going to be tough and I'm still hanging in there! I know the reward will be mighty and after talking to a few classmates, our excitement is growing together as we start to recognize our progress and potential. &lt;/p&gt;

&lt;p&gt;We just started our first group project after a few tough weeks of learning JavaScript and my goal by the end of this project is to have "clicked" with the foundations so I can continue to grow. &lt;/p&gt;

&lt;p&gt;I am thankful for all the support I've been receiving - from classmates, my tutor, the TAs/instructor, and my partner in crime/life. The hardest part was -- I hate to say it -- asking for help. &lt;/p&gt;

&lt;p&gt;In the last week or so, I've been wanting to start capturing this process of my own growth and was jotting down potential writing prompts in my notes so I was excited when my instructor pointed me to this site! Cheers to documenting growth! 🍻 &lt;/p&gt;

&lt;p&gt;Stay tuned or let me know if you have any tips along the way! &lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>bootcamp</category>
      <category>teamwork</category>
    </item>
  </channel>
</rss>
