JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond
-
Upload
valeri-karpov -
Category
Technology
-
view
300 -
download
3
description
Transcript of JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond
![Page 1: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/1.jpg)
MongoDB 2.6, Mongoose 4.0, and Beyond
NodeJS and MongoDB meets ES6 and Browserify
Valeri KarpovSoftware Engineer, MongoDBwww.thecodebarbarian.com
www.slideshare.net/vkarpov15github.com/vkarpov15
@code_barbarian
![Page 2: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/2.jpg)
*
Who Am I?
•CI/NodeJS Engineer at MongoDB
•Maintainer of mongoose ODM
•Former CTO, LevelUp
•MEAN stack apps: Ascot Project, Bookalokal
![Page 3: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/3.jpg)
*
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
![Page 4: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/4.jpg)
*
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)
![Page 5: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/5.jpg)
*
Part I: ES6 Generators and mongoose
![Page 6: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/6.jpg)
*
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
![Page 7: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/7.jpg)
*
Using Generators in ECMAScript 6
•Still need library, such as Q or co
•Special syntax for a function that can yield:• function*() {}
![Page 8: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/8.jpg)
*
Attaining Harmony with Generators
•yield enables try/catch for async code
•Elegant replacement for async.parallel()
![Page 9: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/9.jpg)
*
Using yield with mongoose
•MongoDB 2.6 text search (mongoose >= 3.8.9)
![Page 10: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/10.jpg)
*
Batch save in mongoose
•Without yield:
![Page 11: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/11.jpg)
*
Batch save in mongoose with yield
![Page 12: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/12.jpg)
*
Part II: Mongoose in the Browser
![Page 13: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/13.jpg)
*
Browserify-friendly Schemas
•The dream: same schema in browser and server
•Simplicity: one schema, one language, one validation function
![Page 14: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/14.jpg)
*
The Dream Made Real
![Page 15: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/15.jpg)
*
The Dream Made Real, Part II
![Page 16: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/16.jpg)
*
From Humble Beginnings
![Page 17: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/17.jpg)
*
Browserify Schema Status
•Very very rough proof of concept, not alpha-ready
•Branch on Github
•Also supports ES6 generators :)
![Page 18: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/18.jpg)
*
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
![Page 19: JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond](https://reader031.fdocuments.net/reader031/viewer/2022020207/54b7b78c4a795921278b45ed/html5/thumbnails/19.jpg)
*
Thanks for Listening!
•Slides on:• Twitter: @code_barbarian
• Slideshare: slideshare.net/vkarpov15
•Mongoose on Github