node.js dao       Vova Miguro
What’s it all about?
Node.js is a platform built onChrome’s JavaScript runtime foreasily building fast, scalablenetwork applications.          ...
How?Let’s keep slow operationsfrom blocking otheroperations.
traditional I/Ovar data = file.read(‘image.png’);//zzz...doSomething(data);           something not right here...
async I/Ofile.read(‘image.png’,function(data){  doSomething(image);});doSomethingElse();                     profit!
callback()                          callback()callback()
node.js internals• v8 (yeah, it’s Chrome’s engine)• libev (event loop)• libeio (asynchronous version of  POSIX API)
it is only one thread!file.read(‘file.txt’,function(data){   //will never fire...})while(true){   //blocking entire process}
http servervar http = require(http);http.createServer(function (req, res) { res.writeHead(200, {Content-Type: text/plain})...
watch filevar fs = require(fs);fs.watchFile(system.log,function () { console.log(log changed!);});
node & mongovar mongodb = require(mongodb);var server = new Server(127.0.0.1, 27017, {});new Db(test, server, {}).open(fun...
node & web sockets//servervar io = require(socket.io).listen(80);io.sockets.on(connection, function (socket) { socket.emit...
let’s see...
suited for...• real time• streaming• process monitoring• JSON API’s
do not use for this...
do not use for this...• CPU heavy apps• data transformation
?
node.js dao
node.js dao
Upcoming SlideShare
Loading in...5
×

node.js dao

3,766

Published on

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,766
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
30
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • node.js dao

    1. 1. node.js dao Vova Miguro
    2. 2. What’s it all about?
    3. 3. Node.js is a platform built onChrome’s JavaScript runtime foreasily building fast, scalablenetwork applications. -nodejs.org
    4. 4. How?Let’s keep slow operationsfrom blocking otheroperations.
    5. 5. traditional I/Ovar data = file.read(‘image.png’);//zzz...doSomething(data); something not right here...
    6. 6. async I/Ofile.read(‘image.png’,function(data){ doSomething(image);});doSomethingElse(); profit!
    7. 7. callback() callback()callback()
    8. 8. node.js internals• v8 (yeah, it’s Chrome’s engine)• libev (event loop)• libeio (asynchronous version of POSIX API)
    9. 9. it is only one thread!file.read(‘file.txt’,function(data){ //will never fire...})while(true){ //blocking entire process}
    10. 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. 11. watch filevar fs = require(fs);fs.watchFile(system.log,function () { console.log(log changed!);});
    12. 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. 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. 14. let’s see...
    15. 15. suited for...• real time• streaming• process monitoring• JSON API’s
    16. 16. do not use for this...
    17. 17. do not use for this...• CPU heavy apps• data transformation
    18. 18. ?
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×