SlideShare uma empresa Scribd logo
1 de 11
Mongo and Node
Node is non blocking ,[object Object]
You can send several instructions to Mongo without waiting on the result
https://github.com/bignomanatee/workstack
Cristkof Native ,[object Object]
That means, of course, Map/Reduce
Comes in two flavors: “Pure” Javascript and “Native” C library driven
github.com/christkv/node-mongodb-native
Going Native Basic CRUD in Mongo Native is NOT THAT HARD http://wonderlandlabs.com/wll_drupal/node/mongo/coll.html And there are benefits – Map/Reduce among them –  to using the native libraries directly.
Mongoose: Schemas and More http://mongoosejs.com/ ,[object Object]
Mongoose   gives you the ability  FORCES you to create schemas for your collections

Mais conteúdo relacionado

Mais procurados

WebAssembly: A New World of Native Exploits on the Browser
WebAssembly: A New World of Native Exploits on the BrowserWebAssembly: A New World of Native Exploits on the Browser
WebAssembly: A New World of Native Exploits on the Browser
Priyanka Aash
 
Text expansion in vim
Text expansion in vimText expansion in vim
Text expansion in vim
mattboehm
 

Mais procurados (19)

Shell.me
Shell.meShell.me
Shell.me
 
Ruby On Google App Engine 2nd Athens Ruby Me
Ruby On Google App Engine 2nd Athens Ruby MeRuby On Google App Engine 2nd Athens Ruby Me
Ruby On Google App Engine 2nd Athens Ruby Me
 
Introduction to webGL
Introduction to webGLIntroduction to webGL
Introduction to webGL
 
Into the Wild with Node.js and Web Apps
Into the Wild with Node.js and Web AppsInto the Wild with Node.js and Web Apps
Into the Wild with Node.js and Web Apps
 
Life with coffee_script
Life with coffee_scriptLife with coffee_script
Life with coffee_script
 
Virtualisation - Vagrant and Docker
Virtualisation - Vagrant and DockerVirtualisation - Vagrant and Docker
Virtualisation - Vagrant and Docker
 
04 12-2018-scp ubnetdef-to_blue_tmp
04 12-2018-scp ubnetdef-to_blue_tmp04 12-2018-scp ubnetdef-to_blue_tmp
04 12-2018-scp ubnetdef-to_blue_tmp
 
Overview: How to Measure your WebApp
Overview: How to Measure your WebAppOverview: How to Measure your WebApp
Overview: How to Measure your WebApp
 
Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
Introduction to Apache Maven
Introduction to Apache MavenIntroduction to Apache Maven
Introduction to Apache Maven
 
Writing your own browser reload functionality
Writing your own browser reload functionalityWriting your own browser reload functionality
Writing your own browser reload functionality
 
Coding in the context era
Coding in the context eraCoding in the context era
Coding in the context era
 
WebAssembly: A New World of Native Exploits on the Browser
WebAssembly: A New World of Native Exploits on the BrowserWebAssembly: A New World of Native Exploits on the Browser
WebAssembly: A New World of Native Exploits on the Browser
 
Text expansion in vim
Text expansion in vimText expansion in vim
Text expansion in vim
 
Getting Started with MongoDB and Node.js
Getting Started with MongoDB and Node.jsGetting Started with MongoDB and Node.js
Getting Started with MongoDB and Node.js
 
Django Toolbox
Django ToolboxDjango Toolbox
Django Toolbox
 
Slide Test
Slide TestSlide Test
Slide Test
 
MongoDB Part 2
MongoDB Part 2MongoDB Part 2
MongoDB Part 2
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in Kotlin
 

Semelhante a MongoDB and Node.js

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
carlostorres15106
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Andrey Dotsenko
 

Semelhante a MongoDB and Node.js (20)

Mongodb
MongodbMongodb
Mongodb
 
Mongodb
MongodbMongodb
Mongodb
 
The Little MongoDB Book - Karl Seguin
The Little MongoDB Book - Karl SeguinThe Little MongoDB Book - Karl Seguin
The Little MongoDB Book - Karl Seguin
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
Riereta Node.js session 3 (with notes)
Riereta Node.js session 3 (with notes)Riereta Node.js session 3 (with notes)
Riereta Node.js session 3 (with notes)
 
Mongo db report
Mongo db reportMongo db report
Mongo db report
 
Invitation to mongo db @ Rakuten TechTalk
Invitation to mongo db @ Rakuten TechTalkInvitation to mongo db @ Rakuten TechTalk
Invitation to mongo db @ Rakuten TechTalk
 
Beyond the MEAN Stack: Thinking Small with Node.js for the Enterprise
Beyond the MEAN Stack: Thinking Small with Node.js for the EnterpriseBeyond the MEAN Stack: Thinking Small with Node.js for the Enterprise
Beyond the MEAN Stack: Thinking Small with Node.js for the Enterprise
 
From Zero to Mongo, Art.sy Experience w/ MongoDB
From Zero to Mongo, Art.sy Experience w/ MongoDBFrom Zero to Mongo, Art.sy Experience w/ MongoDB
From Zero to Mongo, Art.sy Experience w/ MongoDB
 
Mdb dn 2016_07_elastic_search
Mdb dn 2016_07_elastic_searchMdb dn 2016_07_elastic_search
Mdb dn 2016_07_elastic_search
 
Mango Database - Web Development
Mango Database - Web DevelopmentMango Database - Web Development
Mango Database - Web Development
 
NodeJS
NodeJSNodeJS
NodeJS
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Es build presentation
Es build presentationEs build presentation
Es build presentation
 
Intro to Docker and clustering with Rancher from scratch
Intro to Docker and clustering with Rancher from scratchIntro to Docker and clustering with Rancher from scratch
Intro to Docker and clustering with Rancher from scratch
 
Mongodb
MongodbMongodb
Mongodb
 
Node.js and MongoDB from scratch, fully explained and tested
Node.js and MongoDB from scratch, fully explained and tested Node.js and MongoDB from scratch, fully explained and tested
Node.js and MongoDB from scratch, fully explained and tested
 
Triple Blitz Strike
Triple Blitz StrikeTriple Blitz Strike
Triple Blitz Strike
 
S&T What I know about Node 110817
S&T What I know about Node 110817S&T What I know about Node 110817
S&T What I know about Node 110817
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

MongoDB and Node.js

Notas do Editor

  1. I was going for a super butch shot of Mongolian warriors … but she is just so adorable!
  2. Node is a language written in the style of the Mongol warrior. When Mongol warriors went through a village chopping off heads they didn't wait for the heads to hit the ground before moving on to the next one. Similarly in Node, you can simply pass along a callback to be executed at the end of a long action – and its more than likely that that long action is repository related. Even though Mongo itself is relatively non-blocking, there are many times when there is no real reason to wait around for a specific action to execute before getting on with your life. Sometimes though you might want aggregate blocking. i.e., “I want to do a series of inserts – possibly to more than one collection. I don't care which order they execute in or which one ends first, but I do want to know when ALL of them are done. I wrote a special library for aggregate action tracking. It is really just decoration of the onTimeout with a tracker that increments when you add actions and decrements when all the actions are done – when the tracking index is zero (or less ? ) a callback is fired off.
  3. Christkof Native is the low level gateway that almost all Node users rely on to access Mongo data. It is also the gateway that Mongoose uses. Anything you can do in Mongo you can do in Native – that includes commands, map reduce, etc. Native provides c-based bindings to the Mongo libraries; however it also provides “Pure” Javascript based access to Mongo that does not rely on the c libraries. Why would you want to not use the c bindings? If for some reason the c libraries don't work in a given environment, you are still guaranteed to have a way to get at your database. Sometimes it is nice in testing to be able to log activity through Native
  4. If you understand how Node works – and that alone is a hump – using native is not that tough. I wrote a model wrapper for native that gives you get, put, find, etc. Note that neither Native nor my custom library is “Active Record” in the last – it operates on raw JavaScript (JSON) Objects and doesn't do any checking against schema, content, or whatever. This means the code that calls it is responsible for ensuring that the data you send to the database is good, consistent with your app, etc. My custom hack lacks a lot of the features that make Mongoose awesome – chiefly, a native schema – but that also means I have full access to Native, which is great if you care about things like Map/Reduce.
  5. Mongoose is all about the schema – it adds to Mongo what people most miss when they start using Mongo – a defined, type aware schema that allows – by which I mean forces – you to submit data in a specific format. While you can put un-schema'd data in a field by defining the field's schema as an empty object {}, at least in the root of the document every field must be defined in the schema or it is not submitted to the database. This is a fine way to operate and it gives you yet another way to tell the snarky SQL people to go fuck themselves, it is definitely an editorial decision by the Mongoose people. You also get implicit transactions in that when you attempt to write, you get blocked if fields that you haven't changed since you read a record are changed when you write it. Once again, blow me, SQL, you got nothing we don't. The one area that Mongoose violates the non-blocking rule is the one area in which it should. Mongoose blocks until it connects to your database preventing you from issuing commands to a dead connection.
  6. While I haven't played with Mongolian Deadbeef, it looks interesting and is worth noting as it is a very fast gateway and has some pretty impressive metrics in the repo. It is another illustration of how easy it is to work with and/or around Mongo Native in Node. It is interesting to me because he very closely maps the mongo shell syntax to node, where native and especially Mongoose (and my own code) take the modelling approach and attempt to force mongo to express itself like a classical or activeRecord based ORM.
  7. Noogle is actually a web spider optimized to poll the chat logs of the Node.js channel. The Noogle front page uses a map-reduced database of word frequencies. This is based on EVERY WORD of every conversation in the last year on the channel, with stopwords removed. Honestly the best search engine for this sort of application is probably still Solr, but the fact that you can take this kind of a survey across the conversations in Mongo is pretty bitchin. The full map/reduce cycle to produce this report takes several minutes to a half hour. I am working on a way to make that process incremental so that going forward I don't have to re-poll the entire history to produce this report.
  8. Here are the results for a search on “callback”. The full list is 3,319 items long. (to come- pagination)
  9. Here is a single conversation. There isn't any “intelligent polling” to remove the elements of the conversation that don't relate to the search terms – in practice I just didn't see the payoff in this particular application when there are other areas including personalization that I want to develop. I grab around 300 lines of conversation around the line clicked on from the previous screen and display them here.