Straight to the video tutorial
Https://v.qq.com/x/page/d0645s79xrq.html
Objective
This is the kitten's second node tutorial, the first tutorial is a simple test of water, the kitten's node tutorial is object-oriented for the Web front-end engineers who have no back-end development experience but have an understanding of node, with every few minutes of videos and blogs, learn node from the easy-to-digest. So learn node with the kitten, the kitten looks forward to the continued attention of the pro.
Today will bring you an e-commerce show small site, using EXPRESS,EJS,MONGODB building (do not ask the Meow technology selection problem, this article is focused on small white front-end understanding of the full stack development), mainly used to let everyone on the express frame of node, There is a basic understanding of how to use the template engine and database in node. Through this tutorial, you will have a basic understanding of all-stack development and the ability to formally begin to enter the full stack of engineers of the threshold Oh.
To get the code in the article, please reply: code
The first is the technical introduction
Express
The first node tutorial has also been introduced:
Based on node. JS platform, a fast, open, minimalist web development framework, mainly used to do simple routing functions, mainly using GET, static resource management.
Ejs
The more common node template engine, the Web front-end small partners on the template engine must be familiar with it?
This article will take Ejs as an example of how to introduce a template engine in node, mainly using the Ejs foreach and basic data output.
Mongodb
MongoDB is a database based on distributed file storage. Written by the C + + language. Designed to provide scalable, high-performance data storage solutions for Web applications.
MongoDB is a product between a relational database and a non-relational database, and is the most versatile and most like relational database in a non-relational database.
This example is mainly used,
Connect to the database (connect), create a collection (createcollection), insert data (insertmany), delete data (Deletemany), find data (find) and other APIs, which are described in detail later in the code
Ideas:
1. Use Express to build Web services and simple routing
The code looks like this: the previous tutorial introduced the Get method, which is no longer described here
2. Manage static resources with Express: static resource Management You can specify a static resource root directory so that static resources can be routed by directory, without having to individually customize the routing
3. Introduction of the Ejs template engine
4. Connect to the MongoDB database and use MongoDB to store commodity information
First we have to install the MongoDB database, the specific installation method can be seen http://www.runoob.com/mongodb/mongodb-tutorial.html
Run the command to start the MongoDB database service, the default port is 27017
Second, connect the database (connect), create the collection (CreateCollection), and store the product information (Insertmany)
5. Read the product information from the MONGODB database and output it to the page
The MONGODB,API used here is the rule that Find,find accepts parameters for querying data, and returns all when an empty object is passed in.
6. Final collation of the code:
Get all the code please reply "code"
PostScript :
These days experienced a lot of slander, was said to cheat powder, was said to have a routine, was said to use their own image propaganda nausea, was said technology is too water. Also let Ben meow these days full of negative energy.
But this meow to emphasize the original intention to do this, Ben Meow this tutorial never thought to show off their more awesome technology, just want to let more front-end engineers can enter the field of full stack development, want to let more people get started node, full of achievement of learning to go on.
Kitten is not a computer professional students, a long time ago, kittens have been self-taught front-end, experienced a very painful, knowledge-free entry period, as if there is a thin layer of window paper, when in front of me, behind is the program of the world's bustling and varied. Ben was fortunate enough to read a book, "JavaScript DOM programming art," which is not the actual principle, but follow the book, you will find that you quickly made something, very fulfilling, I also followed the book into the world of JavaScript, through the Book of Learning, Back to the "Javascipt Advanced Programming", Rhino books and so on.
So the kitten has always felt that there is a simple basis for a quick sense of accomplishment of the tutorial, to lead the novice has a sense of accomplishment has the work of entry into a field is very important , kitten want to do this important person. And I think it's a very meaningful thing.
The kitten began to do it, and had not thought about what to expect in return, more to become a technical preacher of the dream.
If you learn the kitten in the tutorial, you get the harvest, I hope you can share to more people, but also to the support of this meow, also gave the kitten to continue to do this thing momentum.
Kitten is very open-minded to accept everyone's criticism and opinions, but the dream of being laughed to have the value of practice is not it, the kitten will stick to their own way, do what they want to do.
The tutorial has comments and suggestions, please leave a message, and the cat's public number to accept everyone's contribution ~ As long as the content is good, there is no very strong promotion of commercial nature, kitten here there is nothing so-called business cooperation! If used, the nearby pro-kitten can please eat!
Finally, I wish you all can forget beginner's mind, work hard to dream, live hard, live hard ~
I am a cat that has been working hard!
Just a few minutes with the kitten Front end (video tutorial included): Nodejs Basic Express, Ejs, Mongdb building a simple website