bangundwi / intermediate-node-course Goto Github PK
View Code? Open in Web Editor NEWan intermediate node.js course
Home Page: https://lab.github.com/everydeveloper/intermediate-nodejs-course
an intermediate node.js course
Home Page: https://lab.github.com/everydeveloper/intermediate-nodejs-course
Hey there, fellow programmer!
Welcome to the Intermediate Node.js course! If you are taking this course, I am assuming you know the basics of Node.js and Express.js. If not, a good place to start is the intro to node and express course, here on GitHub Learning Lab.
In this tutorial, you will learn how to connect your server to a NoSQL database called MongoDB. You will also learn how to refactor repetitive code, to make it easier to maintain. By the end of this you have a Rest API that can Create, Read, Update, and Delete (CRUD) documents in MongoDB.
This is an interactive tutorial. At the end of each section, you will be prompted to do something to continue. If you don't get a response right away, try refreshing your browser.
Leave a comment about something you would like to Create, Read, Update, and Delete to continue
Let's start by making a User model for mongodb using the mongoose library. This will be the template used to describe what each individual document will look like in our collection.
Find the "models" directory in the root of your project and open "User.js", then add this code to it:
const mongoose = require('mongoose');
const UserSchema = new mongoose.Schema({
name: { type: String, required: true },
email: { type: String, required: true, unique: true },
password: { type: String, required: true }
});
module.exports= mongoose.model('User',UserSchema)
Looks like a JS object doesn't it? That is one of the cool things about MongoDB, it is easy to transfer data from the frontend to the backend. Think of this as a factory, or mold, that can create new User documents in a User collection.
Looking at the model above, which key (name, email, or password) needs to have unique values?
Leave a comment with your answer to continue
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.