Skip to main content

Posts

Seven RESTful Routes You Should Know!

I have been followed the course to develop several app projects. They all follow the RESTful route pattern. Today, I learned many key points about RESTful and would like to share my study note here. What Is REST? REST stands for representational state transfer. I don't know what does this mean, but it is not important right now. You just need to know that REST is just a pattern for defining our routes. What's The Point Of REST? The important things for us is to define what REST is. REST is a way of mapping HTTP routes and CRUD functionality together. By the way CRUD stands for Create, Read, Update, and Destroy. The point of REST is that we don't do whatever we want. Instead, we follow a pattern. It is also more reliable so that if we are interacting with a restful API, it follows a particular pattern. Seven RESTful Routes The course lists the seven route table. It just acts as a pattern that we can fill in the blanks when we develop our own App. screen...

Database Project Study: How To Use Mongoose To Model Your Database?

What is Mongoose? According to Mongoose , Mongoose is an elegant MongoDB object modeling for Node.js. It provides a straight-forward, schema-based solution to model your application data. Basically, Mongoose is a package which helps us interact with Mongo DB. It is a JavaScript layer on top of Mongo DB, and it adds some extra special methods that makes our live easier. How to Install Mongoose? The installation is very simple. We just need to npm install mongoose in our server. Then, we create a JavaScript file, and require the mongoose. Since the Mongoose needs to interact with MongoDB, we need to open another terminal window to call "./mongod"and make sure the MongoDB is running .  Then, we connect Mongoose with MongoDB: mongoose.connect("mongodb://localhost/score_app") . Score Database Project Study In this project, I am going to create a score app which contains student score data. The score data includes three main entries: name...

Database Study Note: Four Basic MongoDB Commands You Should Know

MongoDB is one of the most popular database with Node.js and Express.js. It is a NoSQL database. From Google Image Firstly, we need to install MongoDB in our server. The course TA created a good installation tutorial video on YouTube. Since the MongoDB has updated its system. In the installation, we need to set up the   Ubuntu 16.04 (Xenial)   code instead of 14.04 version which is shown on the video. Once we finish the installation, we need to call "./mongod" and run the code, then open a new terminal window, and call "mongo" , then you are ready to use Mongo shell, which is like JavaScript console.  We can type "help" to learn the main MongoDB commands and their explanation .  After I learned this lecture, I summarized four basic MongoDB commands to do with your database: insert, find, update and remove. Insert I want to create a student databases which include student name and GPA score. I can use insert command to create t...

Database Study Note: What's The Difference Between SQL and NoSQL?

What is Database? According to the course, the database is not only a collection of information data, but it also an interface to interact with data such as add new data, remove data, or edit data. Two Broad Categories of Database: SQL (sequel) SQL is also called relational database. Sequel database are tabular database which data is stored in a table.  From Google Image NoSQL(non-sequel) For NoSQL, they are no tables, and it is basically JavaScript objects with a bunch of key value pairs. What's the difference between SQL and NoSQL? SQL has been around the longest. When we mention database, most people include myself first think of table. Everything is tabular, and if we want to relate data, we have to build other tables to relate that data. However, NoSQL is non-relational database, so we don't have to define any tables and patterns. This is a much more flexible structure. The course also mentioned that flexible structure is bette...

API's Study Notes: How To Make API Request With Node?

The course shows us we can make API's requests with Node. The first thing we need to do is to create the "APIs" directory and touch "request.js" file inside that folder. Then, we need to npm install request package in the APIs directory. Once we have done those basic steps, we can start to require the "request" and make a request from a JavaScript file. In the request, we need to have the "url" , so the server knows where it should request the API. Next, we need to have a function. request("url", function(error, response, body) In the function, there are three things we pass in: error, response, and body . Error: it will hold any potential error that we get such as internet disconnect, 404, and etc. It is important to check for an error. Response : it will be the incoming message that we receive Body : it is the actual response body that came back like HTML code For example, in the "request.js" ...

Study Note For API's: These Two Main Data Formats You Should Know

What is API's? API's stands for application programming interface. They are interfaces for code or computers to talk to one another. For example, we can use a Facebook account to login to Instagram. When we connect these two apps, Instagrams will link to and access your Facebook data. When you upload photos on Instagram, it will be automatically uploaded on Facebook, too. We also use a lot of Web API's every day. Web API's generally to communicate via HTTP. For example, we may ask Yelp API's to recommend 10 nearby Sushi restaurants in a certain zip code. Data Formats There are two main formats that web API is responded with: XML and JSON . When we use the internet, we make an HTTP request and get HTML back. API's don't respond with HTML because HTML contains information about the structure of a page. API's respond with data, not structure. XML XML stands for Extended Markup Language. It is syntactically similar to HTML, but it...

Intermediate Express.js: Six Steps To Develop A Post Request (Study Note)

So far I have learned from the course is all about GET Request which is retrieving information. We run app.get("url", function) in our application. Today, the course shows us how to develop a Post Request by creating a simple friends app. The friends app is a list of friends. There is a form at the bottom, so we can submit a new name to add a new friend to the list. How to develop a post request app? Step One: Set up basic route We create a new directory "PostRequestDemo" under "MoreExpress" directory. Then, in this new directory, we install the express and ejs, and also create a new file "app.js". In the app.js file, we require the express, set up the app, and write a test route "home". We want to make sure everything is connect correctly. Then, we write "/friends" route to render to "friends.ejs" page. In the friend.ejs, we write a simple h1 tag "friend list".  Then, we run the app and see...