node. JS Knowledge Point Learning
First, the basic concept
Node.js, or Node, is a platform that can be JavaScript run on the server side. It can be said that Node.js pioneered the javascript development of the first module, the early javascript requirements are very simple, basically written in the functi
instead of displaying it! After the download is the Picture. This is because we did not give an IMG tag to ask the browser to display this imageSurefire PlanIn order for the text to display normally, use the following code:varhttp= require("http");varFs= require("fs");http.Createserver(function(req,Res{ //request for picture if(req.Method == ' GET ' req.URL.substr(-4)==". jpg"){ FS.Stat(__dirname+req.URL,function(err,Stat{ if(err|| !Stat.Isfile()){ Res.Wr
Recently started learning node. js, Basic, deep, express,koa,react,keystone,mongress, And so on all kinds of things about node. js, each of the learning of the confusion, because there is no practice, the feeling of
6 Steps to Learning node. jsFrom just contact with node. js to now, oneself is also all the way to touch tumbling climbed over, although not to say is what master, but for how to learn node. js, still have some personal opinion, t
node. JS Framework Strongloop Learning notes (i)
I am using node. js to do the phone backstage, find the framework found Strongloop quite suitable, but found no Chinese tutorial, so in their own study, do a note, to facilitate other people like me reference (my engl
Learning website: http://www.nodejs.net/a/20141016/232139.html;Note: Describes how to benefit JavaScript as a server-side script through NODEJS Framework web development. The NODEJS framework is a V8-based engine and is the fastest JavaScript engine available today. The Chrome browser is based on V8, and opening 20-30 pages is a smooth one. The NODEJS Standard Web Development Framework Express helps us quickly build web sites that are more efficient t
All asynchronous I/O operations in node. JS will send an event to the event queue when it is finished. The event is provided by the Eventemitter object.node. js Event Loop:The node. JS program starts with the event loop, to the event loop, and all the logic is the callback f
Node. js learning notes
I will share with you the first article about NodeJS-common Javascript knowledge and how to transition from Javascript developers to NodeJS developers (I will not introduce specific frameworks ). Before reading this article, I hope you have some preliminary knowledge about javascript.
Javascript is an interpreted language for prototype mod
combinations to connect multiple MongoDB servers. Example: mongodb://host1:270017, host2://270017, Host3:270017/testdb
Port
The port to use when connecting to the MongoDB server. The default value is 27017
Database
The name of the database to connect to. Default to Admin
Options
The key-value pair for the option used when connecting. You can specify these options on the dbopt and serveropt parameters
Here's an example of co
NodeType togetherAAAAAAAA text nodechildren--is very useful, it only includes element nodes but does not include text nodesAAAAAAAA text node(2) ParentNode, as long as the parent node is unchanged, is not changedExample: Click the link to hide the entire LiAAAAAAAA text node(3) offsetparent--and parentnode are different, it is to get the element used to locate t
1. Callback functionNode is an asynchronous event-driven platform, so we often need to use callback functions in our code.Cases:1 setTimeout (function() {2 console.log (' callback is called '); 3 },2000);2. Standard callback functionThe callback function format in node. JS is conventional, it has two parameters, the first argument is err, the second argument is Data,err is the error message, and data is
=scottcourse=node ',Pathname: '/course/list ',Path: '/course/list ',HREF: ' Http://imooc.com:8080/course/list?from=scottcourse=node#floor1 '}3, Url.format ({Protocol: ' http: ',/* Underlying protocol */slashes:true,/* whether there is a protocol for the double slash */Auth:null,Host: ' imooc.com:8080 ',/* domain or IP address */port:8080,/* Port number */Hostname: ' imooc.com ',Hash:floor1,Search: '? From=s
In node. js, the module corresponds to the file one by one, which means that a node. js file is a module. To export a function as a method of a module:var printname=function(name) { console.log (name);}; Exports.printname=printname;The module is then requested in the Index.js file, using the method of the module
lable end. Output lable:100ms (can calculate intermediate processing time) console.timeend (' lable '); Prints information about the current stack lable. Output trace:lable---------------------- console.trace (' lable '); Assertion syntax: Console.assert (Expression,[message]) //output assertionerror: Abnormal Console.assert (false, ' abnormal slightly ');V. BufferThe appearance of this buffer is basically to solve the situation that JS
();
})();
This is an echo client, which comes in, prints out, and waits silently for the next message. If the message is quit, then graceful exit ~Where the code creates a persistent queue:moneyqueue, the queue is automatically bound to the default Exchange, which is provided by RMQ, so it's persistent, so there's no problem.Because this is just a consumer, unable to work alone, to verify, you can send messages through the RMQ Administration page.http://blog.csdn.net/puncha/article/details/8
Node. JS Database Chapter--mongoose ODM Introduction MongooseAlmost all languages have a native database connection driver, this we have learned on the last time, such as Java Jdbc,mysql-connector, but the actual development in order to pursue efficiency will not use the original connection, not always establish a connection, the last one, Our registration and landing each write a connection operation, at l
pool at the beginning of the program Request to come in and return data to the request by connecting the pools response The request is complete and the connection is returned to the connection pool Disconnect frees resources when exiting a program Using connection pooling can help us better manage database connections Here we have the connection pool code for database creation as follows: Const dbpool={
//Configuration Database
config: {host:"Host Name", Port:"Port number", User:"Databas
complete process of request, routing, and Response.We found in the App.js file inside and App.get ('/', route.index); similar to another routing rule: App.get ('/users ', user.list); As with the previous routing rule, we can tell that This rule means that when we visit Localhost:3000/users, the browser will return the User.list file under the Routes folder through the daemon and return it to the browser results. Sure enough, the browser does pass through this file: Res.send ("respond with a res
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.