Your SlideShare is downloading. ×
0
By       Jorge GarifunaProfessional Web Developer   info@GariDigital.com        213-915-4402    JGari.com/resume   Twitter...
SMS your Name and Email to:       213-985-4413SMS your name & email to: 213-985-4413   JGari.com/resume
1. A Database that stores data (documents)2. A NoSQL Database     1. NoSQL = Not only SQL3.    Uses JSON for interaction  ...
1.    Scalable2.    High performance3.    Open source4.    Written in C++5.    Humongous      SMS your name & email to: 2...
1.   Document-Oriented Storage2.   Full Index Support3.   Replication & High Availability: Mirror across     LAN/WAN4.   A...
1. A Relational Database2. Ideal for every scenario     SMS your name & email to: 213-985-4413   JGari.com/resume
1. Not a Relational Database (RDBMS)2. Not ideal for every scenario     SMS your name & email to: 213-985-4413   JGari.com...
Relational Database Table/Records              MongoDB Collection/Documents id     firstName   lastName    age            ...
1. I dig alpha products2. Beta products are my cut of tea3. I only consider stable productsSMS your name & email to: 213-9...
Credit: Sanjeev MishraSMS your name & email to: 213-985-4413    JGari.com/resume
1. When you need flexibility in your data2. When you want to easily scale3. When your dataset does not have zillions   of ...
MySQL executable                     Oracle executable                     Mongo executablemysqld                         ...
1.     Download from     1. http://www.mongodb.org/downloads2.     Unzip package3.     Run the following from terminal    ...
1.    If added to path in command line type     1. mongod2.    If not on path     1. Access the bin folder on mongo folder...
1.    If added to path in command line type     1. mongo2.    If not on path     1. Access the bin folder on mongo folder ...
1. Databases are created automatically2. Tables are created automatically3. Primary key is created automaticallySMS your n...
SQL Statement                           Mongo Statement   INSERT INTO USERS VALUES(3,5)           db.users.insert({a:3,b:5...
SQL Statement                                         Mongo Statement   INSERT INTO USERS VALUES(3,5)                     ...
SQL Statement                                Mongo Statement  SELECT a,b FROM users                        db.users.find({...
SQL Statement                            Mongo Statement   UPDATE users SET a=1 WHERE               db.users.update({b:q},...
SQL Statement                                          Mongo Statement   DELETE FROM users WHERE z="abc"                  ...
SMS your name & email to: 213-985-4413   JGari.com/resume
Source: http://www.mongodb.org/display/DOCS/Replica+SetsSMS your name & email to: 213-985-4413                     JGari.c...
 On each mongodb instance start service with:         mongod --rest --replSet mysetSource: http://www.mongodb.org/displa...
 Connect to primary server:         mongo --host PRIMARY_IP_OR_NAME     Initialize replica set         rs.initiate()  ...
 Connect to primary server:         mongo --host PRIMARY_IP_OR_NAME     Add a document         db.foo.save({name: “Jor...
Some Node JS stuffSMS your name & email to: 213-985-4413   JGari.com/resume
 Platform built on Google Chrome’s JavaScript  Runtime For building fast, scalable network applications Substitute for ...
 Download from   nodejs.org Run installation   SMS your name & email to: 213-985-4413   JGari.com/resume
var http = require(http);      http.createServer(function (req, res) {       res.writeHead(200, {Content-Type: text/plain}...
1. A Node JS Application Framework2. Uses MVC (model, view, controller) pattern     SMS your name & email to: 213-985-4413...
1.    From the command line run Node Package      Manager     1. sudo npm install -g express       SMS your name & email t...
1.    From the command line run     1. Express ./YOUR_APP_NAME2.    Change into your new app folder     1. cd ./YOUR_APP_N...
1.    Change into your new app folder     1. cd ./YOUR_APP_NAME2.    Run app with node     1. node app3.    On browser go ...
1.    Change into your new app folder     1. cd ./YOUR_APP_NAME2.    Run app with node     1. node app3.    On browser go ...
1.    Download workout web api from     1. https://github.com/donnfelker/workout-tracker2.    Checkout Develop a RESTful A...
 While you think…  Sign up to LAMPsig’s mailing list at:   ▪ http://lampsig.org  Join LAMPsig on Meetup at:   ▪ http://...
1.     http://www.mongodb.org2.     http://nodejs.org3.     http://expressjs.com4.     http://pixelhandler.com/blog/2012/0...
Upcoming SlideShare
Loading in...5
×

A practical intro to web development with mongo db and nodejs when, why and how

1,456

Published on

Big Data, Huge Data and Humongous Data are all those new terms thrown around today to describe the present and future state of the web. But what if you just wanted to start, in fact, what if you just wanted to start small to wrap your head around these concepts? In this talk you will learn a practical way to getting started with MongoDB and NodeJS including:


Installation of MongoDB.
Connecting to MongoDB
Comparison of commands between MongoDB and a relational databases like MySQL.
Adding, removing, updating and selecting data with MongoDB.
Using MongoDB with a programming language.
Replicating data across several servers.
Building a web API with NodeJS & MongoDB
and much more.

Knowing when, why and how to use MongoDB and NodeJS is a valuable skill to have in this market and whether you are a beginner, intermediate or seasoned developer, you’ll acquire enough knowledge to prepare you for the humongous benefits that MongoDB and NodeJS offers.

About the speaker:

Jorge Garifuna is a Professional Software Developer and Consultant with over 15 years of industry experience. His portfolio of technologies include but are not limited to various programming languages, Web 2.0, a diverse number of Frameworks, countless of databases and the latest and greatest in Mobile for popular platforms such as IOS, Android and BlackBerry, among many.

Over the years, Jorge has successfully Designed, Developed and Deployed (DDD) software in the areas of E-Commerce, Project Management, Content Management Systems (CMS), Enterprise Resource Planning (ERP) and Customer Relationship Management (CRM) to name a few. His technologies have been used by many consumers, employees and businesses.

Jorge prides himself as a happy contributor to various Open Source Projects, including the ATK Framework and vTiger CRM to name a few. He has also given various presentations in the topics of: Joomla CMS; ATK Framework; Wordpress; ELGG Social Network Framework; Integration of Linux, Apache, MySQL, SQLite with Mkahawa Cyber Manager and PHP; and Mobile Development for Web, IOS Native and Android Native.

Jorge joined LAMPsig over six years ago and is currently serving as the president of this dynamic LAMP community group.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,456
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "A practical intro to web development with mongo db and nodejs when, why and how"

  1. 1. By Jorge GarifunaProfessional Web Developer info@GariDigital.com 213-915-4402 JGari.com/resume Twitter: @jgarifuna
  2. 2. SMS your Name and Email to: 213-985-4413SMS your name & email to: 213-985-4413 JGari.com/resume
  3. 3. 1. A Database that stores data (documents)2. A NoSQL Database 1. NoSQL = Not only SQL3. Uses JSON for interaction 1. JSON = JavaScript Object Notation4. Managed by 10gen company SMS your name & email to: 213-985-4413 JGari.com/resume
  4. 4. 1. Scalable2. High performance3. Open source4. Written in C++5. Humongous  SMS your name & email to: 213-985-4413 JGari.com/resume
  5. 5. 1. Document-Oriented Storage2. Full Index Support3. Replication & High Availability: Mirror across LAN/WAN4. Auto-Sharding: Scale horizontally5. Map/Reduce: aggregation & data processing6. GridFS: Stire files of any size SMS your name & email to: 213-985-4413 JGari.com/resume
  6. 6. 1. A Relational Database2. Ideal for every scenario SMS your name & email to: 213-985-4413 JGari.com/resume
  7. 7. 1. Not a Relational Database (RDBMS)2. Not ideal for every scenario SMS your name & email to: 213-985-4413 JGari.com/resume
  8. 8. Relational Database Table/Records MongoDB Collection/Documents id firstName lastName age id: 1 firstName: Jorge lastName: Garifuna 1 Jorge Garifuna 85 age: 85 id: 2 2 Jimmy Smith 30 firstName: Jimmy lastName: Smith age: 30 id: 3 firstName: Alan lastName: Jones age: 25 city: Los Angeles state: CA SMS your name & email to: 213-985-4413 JGari.com/resume
  9. 9. 1. I dig alpha products2. Beta products are my cut of tea3. I only consider stable productsSMS your name & email to: 213-985-4413 JGari.com/resume
  10. 10. Credit: Sanjeev MishraSMS your name & email to: 213-985-4413 JGari.com/resume
  11. 11. 1. When you need flexibility in your data2. When you want to easily scale3. When your dataset does not have zillions of joinsSMS your name & email to: 213-985-4413 JGari.com/resume
  12. 12. MySQL executable Oracle executable Mongo executablemysqld oracle mongodmysql sqlplus mongoMySQL term Mongo term/conceptdatabase databasetable collectionindex indexrow BSON documentcolumn BSON fieldjoin embedding and linkingprimary key _id fieldgroup by aggregation Source: http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart SMS your name & email to: 213-985-4413 JGari.com/resume
  13. 13. 1. Download from 1. http://www.mongodb.org/downloads2. Unzip package3. Run the following from terminal 1. sudo mkdir -p /data/db 2. sudo chown `id -u` /data/db4. Add to path 1. Mac example: export PATH=/Users/jgarifuna/jg/net/Dev/db/mongodb-osx-x86_64- 2.2.1-rc0/bin:$PATH 2. Linux example: PATH=/home/jgarifuna/mongo-linux-2.2.1/bin:$PATH SMS your name & email to: 213-985-4413 JGari.com/resume
  14. 14. 1. If added to path in command line type 1. mongod2. If not on path 1. Access the bin folder on mongo folder 2. Type: ./mongodSMS your name & email to: 213-985-4413 JGari.com/resume
  15. 15. 1. If added to path in command line type 1. mongo2. If not on path 1. Access the bin folder on mongo folder 2. Type: ./mongoSMS your name & email to: 213-985-4413 JGari.com/resume
  16. 16. 1. Databases are created automatically2. Tables are created automatically3. Primary key is created automaticallySMS your name & email to: 213-985-4413 JGari.com/resume
  17. 17. SQL Statement Mongo Statement INSERT INTO USERS VALUES(3,5) db.users.insert({a:3,b:5}) SELECT * FROM users db.users.find() UPDATE users SET a=1 WHERE db.users.update({b:q}, {$set:{a:1}}, false, b=q true) DELETE FROM users WHERE db.users.remove({z:abc}); z="abc"Source: http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart SMS your name & email to: 213-985-4413 JGari.com/resume
  18. 18. SQL Statement Mongo Statement INSERT INTO USERS VALUES(3,5) db.users.insert({a:3,b:5})Source: http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart SMS your name & email to: 213-985-4413 JGari.com/resume
  19. 19. SQL Statement Mongo Statement SELECT a,b FROM users db.users.find({}, {a:1,b:1}) SELECT * FROM users db.users.find() SELECT * FROM users WHERE age=33 db.users.find({age:33}) SELECT a,b FROM users WHERE age=33 db.users.find({age:33}, {a:1,b:1}) SELECT * FROM users WHERE age=33 db.users.find({age:33}).sort({name:1}) ORDER BY name SELECT * FROM users WHERE age>33 db.users.find({age:{$gt:33}}) SELECT * FROM users WHERE age!=33 db.users.find({age:{$ne:33}}) SELECT * FROM users WHERE age>33 db.users.find({age:{$gt:33,$lte:40}}) AND age<=40 SELECT * FROM users ORDER BY name db.users.find().sort({name:-1}) DESC SELECT COUNT(*y) FROM users where db.users.find({age: {$gt: 30}}).count() AGE > 30 SELECT COUNT(AGE) from users db.users.find({age: {$exists: true}}).count()Source: http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart SMS your name & email to: 213-985-4413 JGari.com/resume
  20. 20. SQL Statement Mongo Statement UPDATE users SET a=1 WHERE db.users.update({b:q}, {$set:{a:1}}, false, b=q true) UPDATE users SET a=a+2 WHERE db.users.update({b:q}, {$inc:{a:2}}, false, b=q true)Source: http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart SMS your name & email to: 213-985-4413 JGari.com/resume
  21. 21. SQL Statement Mongo Statement DELETE FROM users WHERE z="abc" db.users.remove({z:abc});Source: http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart SMS your name & email to: 213-985-4413 JGari.com/resume
  22. 22. SMS your name & email to: 213-985-4413 JGari.com/resume
  23. 23. Source: http://www.mongodb.org/display/DOCS/Replica+SetsSMS your name & email to: 213-985-4413 JGari.com/resume
  24. 24.  On each mongodb instance start service with:  mongod --rest --replSet mysetSource: http://www.mongodb.org/display/DOCS/Replica+Sets+-+Basics SMS your name & email to: 213-985-4413 JGari.com/resume
  25. 25.  Connect to primary server:  mongo --host PRIMARY_IP_OR_NAME  Initialize replica set  rs.initiate()  Add secondary node to replica set  rs.add(‘FIRST_SERVER_NAME_OR_IP’)  Add arbiter node to replica set  rs.addArb(‘ARB_SERVER_NAME_OR_IP’)Source: http://www.mongodb.org/display/DOCS/Replica+Sets+-+Basics SMS your name & email to: 213-985-4413 JGari.com/resume
  26. 26.  Connect to primary server:  mongo --host PRIMARY_IP_OR_NAME  Add a document  db.foo.save({name: “Jorge Garifuna”})  Set secondary to slave (otherwise you wont be able to see data)  rs.slaveOk()  Query secondary  db.foo.find()Source: http://www.mongodb.org/display/DOCS/Replica+Sets+-+Basics SMS your name & email to: 213-985-4413 JGari.com/resume
  27. 27. Some Node JS stuffSMS your name & email to: 213-985-4413 JGari.com/resume
  28. 28.  Platform built on Google Chrome’s JavaScript Runtime For building fast, scalable network applications Substitute for Apache/PHP  But you create your own server code SMS your name & email to: 213-985-4413 JGari.com/resume
  29. 29.  Download from  nodejs.org Run installation SMS your name & email to: 213-985-4413 JGari.com/resume
  30. 30. var http = require(http); http.createServer(function (req, res) { res.writeHead(200, {Content-Type: text/plain}); res.end(Hello Worldn); }).listen(1337, 127.0.0.1); console.log(Server running at http://127.0.0.1:1337/);1. Create new folder2. Create testserver.js file and place within folder3. Run node 1. Node testserver.js4. On browser go to: http://127.0.0.1:1337 SMS your name & email to: 213-985-4413 JGari.com/resume
  31. 31. 1. A Node JS Application Framework2. Uses MVC (model, view, controller) pattern SMS your name & email to: 213-985-4413 JGari.com/resume
  32. 32. 1. From the command line run Node Package Manager 1. sudo npm install -g express SMS your name & email to: 213-985-4413 JGari.com/resume
  33. 33. 1. From the command line run 1. Express ./YOUR_APP_NAME2. Change into your new app folder 1. cd ./YOUR_APP_NAME3. Install depedencies 1. npm install -d SMS your name & email to: 213-985-4413 JGari.com/resume
  34. 34. 1. Change into your new app folder 1. cd ./YOUR_APP_NAME2. Run app with node 1. node app3. On browser go to URL: 1. http://localhost:3000 SMS your name & email to: 213-985-4413 JGari.com/resume
  35. 35. 1. Change into your new app folder 1. cd ./YOUR_APP_NAME2. Run app with node 1. node app3. On browser go to URL: 1. http://localhost:3000 SMS your name & email to: 213-985-4413 JGari.com/resume
  36. 36. 1. Download workout web api from 1. https://github.com/donnfelker/workout-tracker2. Checkout Develop a RESTful API Using Node.js With Express and Mongoose 1. http://pixelhandler.com/blog/2012/02/09/develop-a- restful-api-using-node-js-with-express-and- mongoose/ SMS your name & email to: 213-985-4413 JGari.com/resume
  37. 37.  While you think…  Sign up to LAMPsig’s mailing list at: ▪ http://lampsig.org  Join LAMPsig on Meetup at: ▪ http://www.meetup.com/LAMPsig  Jorge Garifuna ▪ info@GariDigital.com ▪ @jgarifunaSMS your name & email to: 213-985-4413 JGari.com/resume
  38. 38. 1. http://www.mongodb.org2. http://nodejs.org3. http://expressjs.com4. http://pixelhandler.com/blog/2012/02/09/dev elop-a-restful-api-using-node-js-with- express-and-mongoose5. http://lampsig.org6. http://www.meetup.com/LAMPsig SMS your name & email to: 213-985-4413 JGari.com/resume
  1. A particular slide catching your eye?

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

×