Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
A Guide to the MEAN Stack
Tips and Tricks for using MongoDB and NodeJS
in overwhelmingly awesome ways
Valeri Karpov
CTO, A...
What is The Ascot Project?
Making fashion geek-friendly
Less like this More like this
Who is this guy?
- Academy for Telecommunications and
Computer Science '07, Princeton CS '11
- Co-founder and CTO, SCVNGR ...
What is this all about?
- Why Ascot uses MongoDB
- What's the MEAN stack and why its awesome
- How MongoDB fits in the MEA...
Why MongoDB?
1) It's cool
2) No joins for nested data
3) Flexible and simple
SQL is Annoying
MEAN Stack
Web dev framework for NodeJS
Superheroic frontend framework
Event-based concurrency environment
MEAN Stack – Why do I care?
- Write one language
- With MongoDB and Mongoose, easy and flexible data
validation
- With Nod...
Same Language, Same Objects
{ "_id" : ObjectId("5161a58b46341f8a46000003"),
"username" : "vkarpov" }
{ "_id" : "5161a58b46...
How MongooseJS Works
MongooseJS – code-defined schemas for MongoDB + NodeJS
- MongoDB and NodeJS are best friends
- No bui...
How MongooseJS Works
MongooseJS – code-defined schemas for MongoDB + NodeJS
Primary MongooseJS types:
- Schema – structure...
How MongooseJS Works
A Basic MongooseJS Schema
How MongooseJS Works
Using the StockPrice Model
How MongooseJS Works
Sometimes being able to save anything isn't right
How MongooseJS Works
Helpful Error Messages
- Nested JSON errors
summary
- Can use this for very
generic form validation
-...
How MongooseJS Works
Nesting and populating MongooseJS Schemas – an important
distinction that doesn't exist in SQL
Popula...
How MongooseJS Works
Can't do multi-level population!
How MongooseJS Works
Nesting and populating MongooseJS Schemas
When can we use nested schemas?
Many-to-one
One-to-many
One...
MEAN Stack Superpowers
NodeJS is not just a Javascript web server
- Event based concurrency
- Package manager similar to R...
Example: Bitcoins!
Bitcoin P&L
Step 1 : Web app to display a streaming Bitcoin ticker
- Complex problem – multiple threads, sockets, mutex, e...
Bitcoin P&L
- Enter NodeJS, where this is a back-of-napkin type problem
Bitcoin P&L
- Update frontend periodically? AngularJS makes it easy
Bitcoin P&L
Takeaways
- General problem : your server connecting to other servers
- Example : Ascot links
- Can write mult...
Bitcoin P&L + MongoDB
Model – list of nested stock schemas Routes – get list of stocks, add a new stock
Bitcoin P&L + MongoDB
AngularJS – generic no-reload form wrapper
Bitcoin P&L + MongoDB
Jade – A View To A Kill And the result:
Takeaways
- MEAN Stack is awesome
- Sophisticated frontends
- Multithreaded backends made easy
- MongooseJS helps NodeJS a...
Thanks for Listening!
Further Reading
- Ascot Project : www.ascotproject.com
- AngularJS Form Validation : “How to Easily ...
Upcoming SlideShare
Loading in …5
×

of

The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 1 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 2 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 3 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 4 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 5 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 6 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 7 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 8 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 9 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 10 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 11 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 12 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 13 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 14 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 15 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 16 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 17 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 18 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 19 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 20 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 21 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 22 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 23 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 24 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 25 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 26 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 27 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 28 The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js Slide 29
Upcoming SlideShare
Introduction To Single Page Application
Next
Download to read offline and view in fullscreen.

120 Likes

Share

Download to read offline

The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js

Download to read offline

Tips and tricks for using MongoDB and Node.js

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js

  1. A Guide to the MEAN Stack Tips and Tricks for using MongoDB and NodeJS in overwhelmingly awesome ways Valeri Karpov CTO, Ascot Project www.thecodebarbarian.com @code_barbarian github.com/vkarpov15
  2. What is The Ascot Project? Making fashion geek-friendly Less like this More like this
  3. Who is this guy? - Academy for Telecommunications and Computer Science '07, Princeton CS '11 - Co-founder and CTO, SCVNGR in '08 - Google intern '09, mentored by Misko Hevery - Tower Research Capital '11 – '13 - Developed Ascot Project at AngelHack DC in '12
  4. What is this all about? - Why Ascot uses MongoDB - What's the MEAN stack and why its awesome - How MongoDB fits in the MEAN stack - Why MongooseJS is important and tradeoffs in it's usage - Example of a cool MEAN stack web app
  5. Why MongoDB? 1) It's cool 2) No joins for nested data 3) Flexible and simple
  6. SQL is Annoying
  7. MEAN Stack Web dev framework for NodeJS Superheroic frontend framework Event-based concurrency environment
  8. MEAN Stack – Why do I care? - Write one language - With MongoDB and Mongoose, easy and flexible data validation - With NodeJS, never need threads - With AngularJS, dynamic client-side templates
  9. Same Language, Same Objects { "_id" : ObjectId("5161a58b46341f8a46000003"), "username" : "vkarpov" } { "_id" : "5161a58b46341f8a46000003", "username" : "vkarpov" } { "_id" : "5161a58b46341f8a46000003", "username" : "vkarpov" }
  10. How MongooseJS Works MongooseJS – code-defined schemas for MongoDB + NodeJS - MongoDB and NodeJS are best friends - No built-in schemas or validation - But, MongoDB native wrapper for NodeJS is lacking:
  11. How MongooseJS Works MongooseJS – code-defined schemas for MongoDB + NodeJS Primary MongooseJS types: - Schema – structure defining how documents look - Connection – Wrapper around database connection - Model = Schema + Connection + collection name - Document is an instantiation of a Model
  12. How MongooseJS Works A Basic MongooseJS Schema
  13. How MongooseJS Works Using the StockPrice Model
  14. How MongooseJS Works Sometimes being able to save anything isn't right
  15. How MongooseJS Works Helpful Error Messages - Nested JSON errors summary - Can use this for very generic form validation - More on this later
  16. How MongooseJS Works Nesting and populating MongooseJS Schemas – an important distinction that doesn't exist in SQL Populate – similar to SQL join Nest – re-use schema in another schema
  17. How MongooseJS Works Can't do multi-level population!
  18. How MongooseJS Works Nesting and populating MongooseJS Schemas When can we use nested schemas? Many-to-one One-to-many One-to-one Many-to-many
  19. MEAN Stack Superpowers NodeJS is not just a Javascript web server - Event based concurrency - Package manager similar to Rails gems - Makes multithreaded servers easy
  20. Example: Bitcoins!
  21. Bitcoin P&L Step 1 : Web app to display a streaming Bitcoin ticker - Complex problem – multiple threads, sockets, mutex, etc. - People in HFT get paid crazy money to do this in C++
  22. Bitcoin P&L - Enter NodeJS, where this is a back-of-napkin type problem
  23. Bitcoin P&L - Update frontend periodically? AngularJS makes it easy
  24. Bitcoin P&L Takeaways - General problem : your server connecting to other servers - Example : Ascot links - Can write multi-threaded servers, but why? - General problem : updating page without reload - AngularJS two-way data binding
  25. Bitcoin P&L + MongoDB Model – list of nested stock schemas Routes – get list of stocks, add a new stock
  26. Bitcoin P&L + MongoDB AngularJS – generic no-reload form wrapper
  27. Bitcoin P&L + MongoDB Jade – A View To A Kill And the result:
  28. Takeaways - MEAN Stack is awesome - Sophisticated frontends - Multithreaded backends made easy - MongooseJS helps NodeJS and MongoDB play nice - Limitations on MongooseJS population
  29. Thanks for Listening! Further Reading - Ascot Project : www.ascotproject.com - AngularJS Form Validation : “How to Easily Validate Any Form Ever Using AngularJS” @ www.thecodebarbarian.com - SocketIO Bitcoin Price Streaming : mtgox-socket-client on NPM and Github - Bitcoin realtime P&L : github.com/vkarpov15/bitcoin-pnl, coming soon to www.thecodebarbarian.com
  • HaleyWalker15

    Nov. 29, 2021
  • camachat

    Jan. 31, 2018
  • phanikoundinya

    Dec. 30, 2017
  • warrenf

    Nov. 15, 2017
  • OlawaleHamzaAnimsaun

    May. 26, 2017
  • FulvioBottoni1

    Apr. 5, 2017
  • AthiththanKathirgama

    Mar. 30, 2017
  • JimmyMillerMBAMS

    Jan. 8, 2017
  • MoeidSaleem

    Dec. 24, 2016
  • williammdavis

    Dec. 4, 2016
  • MiwaNakamoto

    Nov. 26, 2016
  • bbog2006

    Nov. 12, 2016
  • IdoTandy

    Oct. 29, 2016
  • blackcaezar

    Oct. 22, 2016
  • YadavDeepak1

    Sep. 23, 2016
  • akirahiramoto3

    Aug. 28, 2016
  • TomHoltz

    Aug. 11, 2016
  • vhsu

    Jul. 19, 2016
  • jespinoz

    Jul. 16, 2016
  • gaurav_iiit

    Jun. 15, 2016

Tips and tricks for using MongoDB and Node.js

Views

Total views

78,020

On Slideshare

0

From embeds

0

Number of embeds

4,506

Actions

Downloads

1,030

Shares

0

Comments

0

Likes

120

×