js-il keynote: mongodb 2.6, mongoose 4.0, and beyond

Post on 15-Jan-2015

298 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

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

*

Who Am I?

•CI/NodeJS Engineer at MongoDB

•Maintainer of mongoose ODM

•Former CTO, LevelUp

•MEAN stack apps: Ascot Project, Bookalokal

*

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

*

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)

*

Part I: ES6 Generators and mongoose

*

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

*

Using Generators in ECMAScript 6

•Still need library, such as Q or co

•Special syntax for a function that can yield:• function*() {}

*

Attaining Harmony with Generators

•yield enables try/catch for async code

•Elegant replacement for async.parallel()

*

Using yield with mongoose

•MongoDB 2.6 text search (mongoose >= 3.8.9)

*

Batch save in mongoose

•Without yield:

*

Batch save in mongoose with yield

*

Part II: Mongoose in the Browser

*

Browserify-friendly Schemas

•The dream: same schema in browser and server

•Simplicity: one schema, one language, one validation function

*

The Dream Made Real

*

The Dream Made Real, Part II

*

From Humble Beginnings

*

Browserify Schema Status

•Very very rough proof of concept, not alpha-ready

•Branch on Github

•Also supports ES6 generators :)

*

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

*

Thanks for Listening!

•Slides on:• Twitter: @code_barbarian

• Slideshare: slideshare.net/vkarpov15

•Mongoose on Github

top related