SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
Lessons in Open Source from the
MongooseJS ODM
Valeri Karpov
Software Engineer, MongoDB
www.thecodebarbarian.com
www.slideshare.net/vkarpov15
github.com/vkarpov15
@code_barbarian
*
Who Am I?
•NodeJS Engineer at MongoDB
•Maintainer of mongoose ODM
•Former CTO, LevelUp
•Hacker in Residence at BookaLokal
•Author of Professional AngularJS
*
Talk Overview
•How I got into mongoose
•High-level overview of how mongoose works
•Recent new features
•What I’m working on now
•Lessons learned from my first year
*
What is Mongoose?
•MongoDB ODM for NodeJS
•Schema validation for schema-less database
•Neat syntax for building MongoDB operations
•Very active module:
• 400k downloads/month
• 7000 GitHub stars
• 5-20 GitHub issue notifications/day
*
How I got into Mongoose
•Aug 2012: work with janky C++ event loop in HFT
•Nov 2012: start working on fashion startup
•Dec 2012: discover mongoose, cut SLOC in half
•Jan 2013: Leave HFT shop
•Apr 2013: Write original MEAN stack blog post
•Aug 2013: Leave startup land and go to MongoDB
*
How I got into Mongoose
•Dec 2013: Aaron Heckmann leaves MongoDB
•Apr 2014: Handoff over Twitter
*
How does Mongoose Work?
•Core features:
• Schema validation
• Syntactic sugar for persisting documents
• Hooks
*
Part 1: Mongoose Schema Validation
•MongoDB is schema-less...
•But you don’t want end users to store arbitrary data
*
Mongoose Schema Validation
*
Part 2: Syntactic Sugar for Updates
•MongoDB updates look like this:
•
•Do I have to manually build the update part?
*
Object.defineProperty()
•Current JavaScript spec lets you hook into property
access
*
Syntactic Sugar for Updates
•General idea: define mongoose schema
● When creating doc, loop over all schema paths
● For each path, use Object.defineProperty()
● Object.defineProperty() setter converts:
● Into:
● save() applies all updates
*
Part 3: Hooks / middleware
•Schema-level business logic
•Suppose you want to:
• Add a timestamp every time you save()
• Add your own caching layer to queries
• Log every query based on config file setting
*
Hooks / middleware
•Schema-level business logic
*
Hooks => Plugins
•Higher-level concept of “plugins”
•External hooks
*
Recent Additions
•Mongoose 4.0 released March 25
•Sweet new features:
• Query middleware
• Schema validation in the browser
• Validators on update()
*
What I’m Working On Now
•Promises: OOP for async operations
•Single biggest source of mongoose feature requests
*
Promises Explained
•General idea: users don’t like nested callbacks
•See Callback Hell is a Myth
*
Promises Explained
•Promises provide flatter structure
*
This Sounds Great But...
•The promises space is wildly fragmented
•Ask 10 users, get 10 different favorite promises
libraries - Bluebird, Q, RSVP, When, native ES6
•Mongoose promises feature requests are usually
• Use promises library X natively
• Support promises library Y’s feature Z
*
General Solution
•Mongoose 4 uses mpromise natively
•mpromise designed for ease rather than features or
performance, minimal adoption outside of mongoose
•Considering deprecating native promise support
•For now, planned solution is to allow users to specify
promise library of choice
*
Challenges
•Hooks and promises are confusing
•Promises need to be resolved
•Should they be resolved before or after post hooks?
•If after, hooks library needs to handle resolving!
*
Final Bit: Lessons Learned
•Linus’ Law:
•“Given a large enough beta-tester and co-developer
base, almost every problem will be characterized
quickly and the fix will be obvious to someone”
•Open source code is great because of the combined
input of the entire user base
*
Final Bit: Lessons Learned
•When using mongoose, you get contributions from a
lot of smart people
● The value of an OS module is (usually) proportional
to its user base
*
Final Bit: Lessons Learned
•Putting your code in the open makes you go the extra
mile to make it awesome
•And sometimes you have to eat some humble pie
*
First Rule in Running an Open Source
Module
•Always be responsive
•Nothing is worse than opening a github issue and not
having anybody touch it for a month
•Worse: somebody responds and says this library is no
longer maintained
*
Second Rule: Lead with a Clear
Vision
•Not necessarily in conflict with the “get people
involved”
•Easy for a module to become bloated
•One-off contributors aren’t as invested in the module
•Leads to unclear interfaces
•For instance, yeoman Ionic generator
*
ABD: Always Be Dogfooding
•Why I work on BookaLokal, mongoose plugins, etc.
•“Nobody should start to undertake a large project. You
start with a small trivial project, and you should never
expect it to get large... If it doesn't solve some fairly
immediate need, it's almost certainly over-designed... You
need to get something half-way useful first, and then
others will say "hey, that almost works for me", and they'll
get involved in the project.” - Linus Torvalds
*
Thanks for Listening!
•Slides on:
• Twitter: @code_barbarian
• Slideshare: slideshare.net/vkarpov15
•Mongoose on Github

Weitere ähnliche Inhalte

Was ist angesagt?

Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012
Volkan Özçelik
 
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
Valeri Karpov
 
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Corey Clark, Ph.D.
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
Zahid Mahir
 

Was ist angesagt? (19)

MEAN Stack - Google Developers Live 10/03/2013
MEAN Stack - Google Developers Live 10/03/2013MEAN Stack - Google Developers Live 10/03/2013
MEAN Stack - Google Developers Live 10/03/2013
 
JSFoo-2017 Takeaways
JSFoo-2017 TakeawaysJSFoo-2017 Takeaways
JSFoo-2017 Takeaways
 
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
 
External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1)
 
External JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesExternal JavaScript Widget Development Best Practices
External JavaScript Widget Development Best Practices
 
Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012
 
Next generation frontend tooling
Next generation frontend toolingNext generation frontend tooling
Next generation frontend tooling
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
 
Node js projects
Node js projectsNode js projects
Node js projects
 
The Dark Side of Single Page Applications
The Dark Side of Single Page ApplicationsThe Dark Side of Single Page Applications
The Dark Side of Single Page Applications
 
Presentation
PresentationPresentation
Presentation
 
Afrimadoni the power of docker
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of docker
 
The MEAN Stack
The MEAN StackThe MEAN Stack
The MEAN Stack
 
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
 
Testing Mobile JavaScript (Fall 2010
Testing Mobile JavaScript (Fall 2010Testing Mobile JavaScript (Fall 2010
Testing Mobile JavaScript (Fall 2010
 
MEAN Stack
MEAN Stack MEAN Stack
MEAN Stack
 
Bringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkersBringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkers
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 

Andere mochten auch

JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond
JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and BeyondJS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond
JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond
Valeri Karpov
 
Mongo db in 3 minutes BoilerMake
Mongo db in 3 minutes   BoilerMakeMongo db in 3 minutes   BoilerMake
Mongo db in 3 minutes BoilerMake
Valeri Karpov
 
AngularJS Meetup 11/19/13 - AngularJS for MongoDB Continuous Integration
AngularJS Meetup 11/19/13 - AngularJS for MongoDB Continuous IntegrationAngularJS Meetup 11/19/13 - AngularJS for MongoDB Continuous Integration
AngularJS Meetup 11/19/13 - AngularJS for MongoDB Continuous Integration
Valeri Karpov
 
Media presentation of draupadi's choice
Media presentation of draupadi's choiceMedia presentation of draupadi's choice
Media presentation of draupadi's choice
Harry Whitley
 
MongoDB: Queries and Aggregation Framework with NBA Game Data
MongoDB: Queries and Aggregation Framework with NBA Game DataMongoDB: Queries and Aggregation Framework with NBA Game Data
MongoDB: Queries and Aggregation Framework with NBA Game Data
Valeri Karpov
 
Summary of the Mahabharata of Vyasa
Summary of the Mahabharata of VyasaSummary of the Mahabharata of Vyasa
Summary of the Mahabharata of Vyasa
Jasodra Rampersad
 
Bhagavad Gita.ppt
Bhagavad Gita.pptBhagavad Gita.ppt
Bhagavad Gita.ppt
Shama
 
Bhagavad Gita and Management
Bhagavad Gita and ManagementBhagavad Gita and Management
Bhagavad Gita and Management
arthi_shankar
 
Mahabharata.ppt
Mahabharata.pptMahabharata.ppt
Mahabharata.ppt
Shama
 

Andere mochten auch (19)

MongoDB Miami Meetup 1/26/15: Introduction to WiredTiger
MongoDB Miami Meetup 1/26/15: Introduction to WiredTigerMongoDB Miami Meetup 1/26/15: Introduction to WiredTiger
MongoDB Miami Meetup 1/26/15: Introduction to WiredTiger
 
JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond
JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and BeyondJS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond
JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond
 
MongoDB Israel June Meetup
MongoDB Israel June MeetupMongoDB Israel June Meetup
MongoDB Israel June Meetup
 
Mongo db in 3 minutes BoilerMake
Mongo db in 3 minutes   BoilerMakeMongo db in 3 minutes   BoilerMake
Mongo db in 3 minutes BoilerMake
 
AngularJS Meetup 11/19/13 - AngularJS for MongoDB Continuous Integration
AngularJS Meetup 11/19/13 - AngularJS for MongoDB Continuous IntegrationAngularJS Meetup 11/19/13 - AngularJS for MongoDB Continuous Integration
AngularJS Meetup 11/19/13 - AngularJS for MongoDB Continuous Integration
 
JS-IL: Getting MEAN in 1 Hour
JS-IL: Getting MEAN in 1 HourJS-IL: Getting MEAN in 1 Hour
JS-IL: Getting MEAN in 1 Hour
 
Kobietazmelodia
KobietazmelodiaKobietazmelodia
Kobietazmelodia
 
Media presentation of draupadi's choice
Media presentation of draupadi's choiceMedia presentation of draupadi's choice
Media presentation of draupadi's choice
 
Winning strategy -learnt from Mahabarat
Winning strategy -learnt from MahabaratWinning strategy -learnt from Mahabarat
Winning strategy -learnt from Mahabarat
 
MongoDB: Queries and Aggregation Framework with NBA Game Data
MongoDB: Queries and Aggregation Framework with NBA Game DataMongoDB: Queries and Aggregation Framework with NBA Game Data
MongoDB: Queries and Aggregation Framework with NBA Game Data
 
Mahabharat and geeta
Mahabharat and geetaMahabharat and geeta
Mahabharat and geeta
 
NodeSummit - MEAN Stack
NodeSummit - MEAN StackNodeSummit - MEAN Stack
NodeSummit - MEAN Stack
 
Nimrod: MongoDB Shell in NodeJS (JSConfUY 2015)
Nimrod: MongoDB Shell in NodeJS (JSConfUY 2015)Nimrod: MongoDB Shell in NodeJS (JSConfUY 2015)
Nimrod: MongoDB Shell in NodeJS (JSConfUY 2015)
 
MAHABHARATA
MAHABHARATAMAHABHARATA
MAHABHARATA
 
Mahabharata Summary
Mahabharata SummaryMahabharata Summary
Mahabharata Summary
 
Summary of the Mahabharata of Vyasa
Summary of the Mahabharata of VyasaSummary of the Mahabharata of Vyasa
Summary of the Mahabharata of Vyasa
 
Bhagavad Gita.ppt
Bhagavad Gita.pptBhagavad Gita.ppt
Bhagavad Gita.ppt
 
Bhagavad Gita and Management
Bhagavad Gita and ManagementBhagavad Gita and Management
Bhagavad Gita and Management
 
Mahabharata.ppt
Mahabharata.pptMahabharata.ppt
Mahabharata.ppt
 

Ähnlich wie Lessons in Open Source from the MongooseJS ODM

Rd mongo-meetup-2013-05-21
Rd mongo-meetup-2013-05-21Rd mongo-meetup-2013-05-21
Rd mongo-meetup-2013-05-21
Claire Willett
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
Hannes Lowette
 
Selenium at Mozilla: An Essential Element to our Success
Selenium at Mozilla: An Essential Element to our SuccessSelenium at Mozilla: An Essential Element to our Success
Selenium at Mozilla: An Essential Element to our Success
Stephen Donner
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
Hannes Lowette
 
Dev ops lessons learned - Michael Collins
Dev ops lessons learned  - Michael CollinsDev ops lessons learned  - Michael Collins
Dev ops lessons learned - Michael Collins
Devopsdays
 

Ähnlich wie Lessons in Open Source from the MongooseJS ODM (20)

10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
 
Prototyping like it is 2022
Prototyping like it is 2022 Prototyping like it is 2022
Prototyping like it is 2022
 
Developing and Testing a MongoDB and Node.js REST API
Developing and Testing a MongoDB and Node.js REST APIDeveloping and Testing a MongoDB and Node.js REST API
Developing and Testing a MongoDB and Node.js REST API
 
MSCloudCancun 2022 - Power User Guide -Windows 10 integration points to O365
MSCloudCancun 2022 - Power User Guide -Windows 10 integration points to O365MSCloudCancun 2022 - Power User Guide -Windows 10 integration points to O365
MSCloudCancun 2022 - Power User Guide -Windows 10 integration points to O365
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
 
Rd mongo-meetup-2013-05-21
Rd mongo-meetup-2013-05-21Rd mongo-meetup-2013-05-21
Rd mongo-meetup-2013-05-21
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
 
The New Frontend Toolchain
The New Frontend ToolchainThe New Frontend Toolchain
The New Frontend Toolchain
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1
 
Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Untangling - fall2017 - week 7
Untangling - fall2017 - week 7
 
A 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developersA 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developers
 
Selenium at Mozilla: An Essential Element to our Success
Selenium at Mozilla: An Essential Element to our SuccessSelenium at Mozilla: An Essential Element to our Success
Selenium at Mozilla: An Essential Element to our Success
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
 
CPAN Curation
CPAN CurationCPAN Curation
CPAN Curation
 
Coonti in HelsinkiJS
Coonti in HelsinkiJSCoonti in HelsinkiJS
Coonti in HelsinkiJS
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
 
Dev ops lessons learned - Michael Collins
Dev ops lessons learned  - Michael CollinsDev ops lessons learned  - Michael Collins
Dev ops lessons learned - Michael Collins
 
CodeIgniter for Startups, cicon2010
CodeIgniter for Startups, cicon2010CodeIgniter for Startups, cicon2010
CodeIgniter for Startups, cicon2010
 
Last Call Media Drupal 8 Case Study
Last Call Media Drupal 8 Case StudyLast Call Media Drupal 8 Case Study
Last Call Media Drupal 8 Case Study
 

Mehr von Valeri Karpov (8)

A Practical Introduction to GeoJSON
A Practical Introduction to GeoJSONA Practical Introduction to GeoJSON
A Practical Introduction to GeoJSON
 
A Practical Introduction to Functions-as-a-Service
A Practical Introduction to Functions-as-a-ServiceA Practical Introduction to Functions-as-a-Service
A Practical Introduction to Functions-as-a-Service
 
A Gentle Introduction to Functions-as-a-Service
A Gentle Introduction to Functions-as-a-ServiceA Gentle Introduction to Functions-as-a-Service
A Gentle Introduction to Functions-as-a-Service
 
Introducing Async/Await
Introducing Async/AwaitIntroducing Async/Await
Introducing Async/Await
 
TAO and the Essence of Modern JavaScript
TAO and the Essence of Modern JavaScriptTAO and the Essence of Modern JavaScript
TAO and the Essence of Modern JavaScript
 
Mastering Async/Await in JavaScript
Mastering Async/Await in JavaScriptMastering Async/Await in JavaScript
Mastering Async/Await in JavaScript
 
React, Redux, and Archetype
React, Redux, and ArchetypeReact, Redux, and Archetype
React, Redux, and Archetype
 
MongoDB API Talk @ HackPrinceton
MongoDB API Talk @ HackPrincetonMongoDB API Talk @ HackPrinceton
MongoDB API Talk @ HackPrinceton
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Lessons in Open Source from the MongooseJS ODM

  • 1. Lessons in Open Source from the MongooseJS ODM Valeri Karpov Software Engineer, MongoDB www.thecodebarbarian.com www.slideshare.net/vkarpov15 github.com/vkarpov15 @code_barbarian
  • 2. * Who Am I? •NodeJS Engineer at MongoDB •Maintainer of mongoose ODM •Former CTO, LevelUp •Hacker in Residence at BookaLokal •Author of Professional AngularJS
  • 3. * Talk Overview •How I got into mongoose •High-level overview of how mongoose works •Recent new features •What I’m working on now •Lessons learned from my first year
  • 4. * What is Mongoose? •MongoDB ODM for NodeJS •Schema validation for schema-less database •Neat syntax for building MongoDB operations •Very active module: • 400k downloads/month • 7000 GitHub stars • 5-20 GitHub issue notifications/day
  • 5. * How I got into Mongoose •Aug 2012: work with janky C++ event loop in HFT •Nov 2012: start working on fashion startup •Dec 2012: discover mongoose, cut SLOC in half •Jan 2013: Leave HFT shop •Apr 2013: Write original MEAN stack blog post •Aug 2013: Leave startup land and go to MongoDB
  • 6. * How I got into Mongoose •Dec 2013: Aaron Heckmann leaves MongoDB •Apr 2014: Handoff over Twitter
  • 7. * How does Mongoose Work? •Core features: • Schema validation • Syntactic sugar for persisting documents • Hooks
  • 8. * Part 1: Mongoose Schema Validation •MongoDB is schema-less... •But you don’t want end users to store arbitrary data
  • 10. * Part 2: Syntactic Sugar for Updates •MongoDB updates look like this: • •Do I have to manually build the update part?
  • 11. * Object.defineProperty() •Current JavaScript spec lets you hook into property access
  • 12. * Syntactic Sugar for Updates •General idea: define mongoose schema ● When creating doc, loop over all schema paths ● For each path, use Object.defineProperty() ● Object.defineProperty() setter converts: ● Into: ● save() applies all updates
  • 13. * Part 3: Hooks / middleware •Schema-level business logic •Suppose you want to: • Add a timestamp every time you save() • Add your own caching layer to queries • Log every query based on config file setting
  • 15. * Hooks => Plugins •Higher-level concept of “plugins” •External hooks
  • 16. * Recent Additions •Mongoose 4.0 released March 25 •Sweet new features: • Query middleware • Schema validation in the browser • Validators on update()
  • 17. * What I’m Working On Now •Promises: OOP for async operations •Single biggest source of mongoose feature requests
  • 18. * Promises Explained •General idea: users don’t like nested callbacks •See Callback Hell is a Myth
  • 20. * This Sounds Great But... •The promises space is wildly fragmented •Ask 10 users, get 10 different favorite promises libraries - Bluebird, Q, RSVP, When, native ES6 •Mongoose promises feature requests are usually • Use promises library X natively • Support promises library Y’s feature Z
  • 21. * General Solution •Mongoose 4 uses mpromise natively •mpromise designed for ease rather than features or performance, minimal adoption outside of mongoose •Considering deprecating native promise support •For now, planned solution is to allow users to specify promise library of choice
  • 22. * Challenges •Hooks and promises are confusing •Promises need to be resolved •Should they be resolved before or after post hooks? •If after, hooks library needs to handle resolving!
  • 23. * Final Bit: Lessons Learned •Linus’ Law: •“Given a large enough beta-tester and co-developer base, almost every problem will be characterized quickly and the fix will be obvious to someone” •Open source code is great because of the combined input of the entire user base
  • 24. * Final Bit: Lessons Learned •When using mongoose, you get contributions from a lot of smart people ● The value of an OS module is (usually) proportional to its user base
  • 25. * Final Bit: Lessons Learned •Putting your code in the open makes you go the extra mile to make it awesome •And sometimes you have to eat some humble pie
  • 26. * First Rule in Running an Open Source Module •Always be responsive •Nothing is worse than opening a github issue and not having anybody touch it for a month •Worse: somebody responds and says this library is no longer maintained
  • 27. * Second Rule: Lead with a Clear Vision •Not necessarily in conflict with the “get people involved” •Easy for a module to become bloated •One-off contributors aren’t as invested in the module •Leads to unclear interfaces •For instance, yeoman Ionic generator
  • 28. * ABD: Always Be Dogfooding •Why I work on BookaLokal, mongoose plugins, etc. •“Nobody should start to undertake a large project. You start with a small trivial project, and you should never expect it to get large... If it doesn't solve some fairly immediate need, it's almost certainly over-designed... You need to get something half-way useful first, and then others will say "hey, that almost works for me", and they'll get involved in the project.” - Linus Torvalds
  • 29. * Thanks for Listening! •Slides on: • Twitter: @code_barbarian • Slideshare: slideshare.net/vkarpov15 •Mongoose on Github