Node. js learning summary on mongodb operations, node. jsmongodb
I. Preparations
1. Create a table to be read in mongodb
Create a database named TestCopy codeThe Code is as follows:Use extension test;Insert data to the user tableCopy codeThe Code is as follows:Db. user. insert ({Name: 'flyoung ',Age: '18 ',Sex: true});
comment or not, by comparing the difference between the time, we can see that the parallel path is not parallel executionConsole.log (New Date ()-T);}, 1000);var T1 = new Date ();Heavycompute (50000);Console.log (' a ');Console.log (New Date ()-T1);It turns out that no one has moved it since the parallel process was created.Summing up, JS is a single-threaded execution, even if the parallel thread inside the function is completed, the callback functi
: node. JS distribution, following the MIT license.
Who Uses node. js?Following is the link on GitHub wiki containing a exhaustive list of projects, application and companies which are using node. js. This list include EBay, Ge
Iii. using node. js for Web Development1. Install Express Express is the officially recommended Web development framework and is very powerful.Enter NPM Install-g Express on the command line for global installation Express This means that the installation is complete. But at this point we do not succeed in executing the express-h command, because express4.0 will need to install the Express-generator p
,response) {//when the client sends a request to the server-side current service (the port number is 80), and the current service has successfully received the request //Request : Holds the request information for all clients, including the data content that the client passes to the server through the question-mark argument //Console.log (Request.url);//The address requested by the client, which is obtained by the server through Request.url, is not including localhost or IP address informa
, using var variable can be output by Console.log ().REPL command
Ctrl + C?- exits the current terminal.
Ctrl + C Press two times ?- Exit Node REPL .
Ctrl + D?- exits Node REPL.
Upward / downward Key ?- View the history command of the input
Tab Key ?- List Current Commands
.help?- list the Use commands
.break?- exit multi-line expression
. Clear?- exit multi-line expression
.
Server for node. JS:
The first line requests (require) node. js's own HTTP module and assigns it to the HTTP variable.
Next we invoke the function provided by the HTTP module: Createserver. This function returns an object that has a method called Listen, which has a numeric parameter that specifies the port number that the HTTP server listens on.
event pattern are also obvious, as it does not conform to the usual linear approach of the developer, often requiring a complete logic split into events, which increases the difficulty of development and debugging. For this issue, the node. JS third-party module presents a number of solutions, which we'll discuss in detail in the 6th chapter. node.
node. JS Getting Started" Gateway node. JS Course "Rapid setup of the node. JS development environment and accelerating NPMHttp://fengmk2.com/blog/2014/03/node-env-and-faster-npm.html"
tests, Some still serve the long link under the polling poll .... Wait a minute. We can refer to the NodeJS specific module list in Http://wiki.github.com/ry/node/modules.Share a node. JS feature site for beginners:http://howtonode.org/Resources for Nodejs and WebSocket:Http://blog.new-bamboo.co.uk/2009/12/7/real-time-online-activity-monitor-example-with-
example, a simple counter design, I login to a URL, it triggers a counter event, very natural. Of course, more importantly, JS language features, namely function, closures, similar C syntax, refining and concise style, and so on, especially Function, simply for the event model, easily coincide with the idea of node. js asynchronous mechanism, is really to attrac
The Connect tool set for HTTP development-middlewareAfter learning about node. JS's TCP API and HTTP API, node. JS Web Development is on the right track, but it's like a Java servlet that we can't use the most basic Servlet object to write a website, and we can't use the most elementary
This article compiles from a stack overflow how to start learning about node. js's wiki post, a resource list that browses close to 600,000 times, thousands of collections, and tops. Specially organized to publish here, which added some Chinese references.Learning Guides and Tutorials
Nodeschool.io Interactive Course
Node's art (node profile)
Hel
This article compiles from a stack overflow how to start learning about node. js's wiki post, a resource list that browses close to 600,000 times, thousands of collections, and tops. Specially organized to publish here, which added some Chinese references.Learning Guides and Tutorials
Nodeschool.io Interactive Course
Node's art (node profile)
Hel
Node. js Learning (2) -- routing and form upload
Today. getting started with js this book has learned some basic knowledge about node, including server creation, implementation of routing functions, form upload and data processing. some basic principles of
. Now that all programmers are in the process of learning a new development language, the first program is to output "Hello World", so let's create a node. JS application that outputs "Hello World". Step One: Create a JS script file to store our node.
callback function. The callback function is the first of the actual arguments is err, and the rest of the arguments are the other returned content. If no error occurs, The value of err will be null or undefined. If an error occurs,err is usually an instance of the Error object. Synchronization mode:Fs.readfilesync (Filename,[encoding]).Fs.openFs.open (Path,flags, [mode], [Callback (Err, FD)])Path, flag is the way to confirm the opening of the file (read-write, read-only, create or not), mode d
This article mainly introduces what is Node. js? What are the advantages of Node. js ?, To try to explain what Node is. js, this article will briefly introduce some background information: the problem to be solved, how it works, h
The main contents of node. JS Core module include: (1) Global Objects (2) common tools (3) event mechanism (4) File system Access (5) HTTP Server and clientOne: Global objectsThe global object in node. JS is globals, and all global variables (except the global itself) are properties of global.The fundamental role of gl
Web developers are increasingly interested in Node. js, and more companies and developers are trying to use it.Node. jsTo implement some I/O-intensive businesses with high real-time requirements.
I introduced some good books and cases to improve the node. js development progress,On the
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.