Your SlideShare is downloading. ×
node.js dao
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

node.js dao

3,532
views

Published on

This presentation from my speech about node.js in miniq club.

This presentation from my speech about node.js in miniq club.

Published in: Technology, Education

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,532
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
28
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. node.js dao Vova Miguro
    • 2. What’s it all about?
    • 3. Node.js is a platform built onChrome’s JavaScript runtime foreasily building fast, scalablenetwork applications. -nodejs.org
    • 4. How?Let’s keep slow operationsfrom blocking otheroperations.
    • 5. traditional I/Ovar data = file.read(‘image.png’);//zzz...doSomething(data); something not right here...
    • 6. async I/Ofile.read(‘image.png’,function(data){ doSomething(image);});doSomethingElse(); profit!
    • 7. callback() callback()callback()
    • 8. node.js internals• v8 (yeah, it’s Chrome’s engine)• libev (event loop)• libeio (asynchronous version of POSIX API)
    • 9. it is only one thread!file.read(‘file.txt’,function(data){ //will never fire...})while(true){ //blocking entire process}
    • 10. http servervar http = require(http);http.createServer(function (req, res) { res.writeHead(200, {Content-Type: text/plain}); res.end(Hello Worldn);}).listen(3000);
    • 11. watch filevar fs = require(fs);fs.watchFile(system.log,function () { console.log(log changed!);});
    • 12. node & mongovar mongodb = require(mongodb);var server = new Server(127.0.0.1, 27017, {});new Db(test, server, {}).open(function (error, client) { var collection = new Collection(client, tmp); //insert doc collection.insert({a:12,b:string},{},function(){ //find doc collection.find({}, {limit:10}).toArray(function(err, docs) { //do smth with docs }); });
    • 13. node & web sockets//servervar io = require(socket.io).listen(80);io.sockets.on(connection, function (socket) { socket.emit(news, {hello:world});});//clientvar socket = io.connect(http://localhost);socket.on(news, function (data) { console.log(data);});
    • 14. let’s see...
    • 15. suited for...• real time• streaming• process monitoring• JSON API’s
    • 16. do not use for this...
    • 17. do not use for this...• CPU heavy apps• data transformation
    • 18. ?