JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond

1,109 views

Published on

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

No Downloads
Views
Total views
1,109
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
16
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond

  1. 1. MongoDB 2.6, Mongoose 4.0, and Beyond NodeJS and MongoDB meets ES6 and Browserify Valeri Karpov Software Engineer, MongoDB www.thecodebarbarian.com www.slideshare.net/vkarpov15 github.com/vkarpov15 @code_barbarian
  2. 2. * Who Am I? •CI/NodeJS Engineer at MongoDB •Maintainer of mongoose ODM •Former CTO, LevelUp •MEAN stack apps: Ascot Project, Bookalokal
  3. 3. * Talk Overview •Exciting developments in JavaScript: • ECMAScript 6 (Harmony) is coming • Browserify is changing the way we use NodeJS • Compiles NodeJS code into browser-friendly form •Mongoose 4.0 (ETA September) + ES6 + Browserify •Also highlight some new features in MongoDB 2.6
  4. 4. * What is Mongoose? •Elegant ODM for MongoDB and NodeJS •ActiveRecord-like Models per MongoDB collection •Syntactic sugar for queries: chaining, fluent syntax • ex: .find().where('answer').equals(42) •Join-like functionality via populate() •Promises/A+ conformant promises •Community authored (same author as socket.io)
  5. 5. * Part I: ES6 Generators and mongoose
  6. 6. * Generators in ECMAScript 6 •ES6 will include a yield keyword •Write async code with less pyramid of doom •NodeJS 0.11.x, use node --harmony
  7. 7. * Using Generators in ECMAScript 6 •Still need library, such as Q or co •Special syntax for a function that can yield: • function*() {}
  8. 8. * Attaining Harmony with Generators •yield enables try/catch for async code •Elegant replacement for async.parallel()
  9. 9. * Using yield with mongoose •MongoDB 2.6 text search (mongoose >= 3.8.9)
  10. 10. * Batch save in mongoose •Without yield:
  11. 11. * Batch save in mongoose with yield
  12. 12. * Part II: Mongoose in the Browser
  13. 13. * Browserify-friendly Schemas •The dream: same schema in browser and server •Simplicity: one schema, one language, one validation function
  14. 14. * The Dream Made Real
  15. 15. * The Dream Made Real, Part II
  16. 16. * From Humble Beginnings
  17. 17. * Browserify Schema Status •Very very rough proof of concept, not alpha-ready •Branch on Github •Also supports ES6 generators :)
  18. 18. * Review •JavaScript has a very exciting future •ES6 Generators make async code human-readable •Browserify makes code sharing a reality •Mongoose will take advantage of this tech •My talk at 11:45: 1 hour to build a MEAN stack app with mongoose and browserify
  19. 19. * Thanks for Listening! •Slides on: • Twitter: @code_barbarian • Slideshare: slideshare.net/vkarpov15 •Mongoose on Github

×