Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
How different are MongoDB
Drivers?
SA, MongoDB
Norberto Leite
#mongobe
{
"name":"Norberto Leite",
"role":"Solutions Architect",
"company":"MongoDB",
"address": ["Barcelona,Spain”,”Brussels,Belg...
Agenda
•  MongoDB Drivers
•  Community vs Official Supported
•  General Considerations
•  Examples
•  Meta Driver Project
MongoDB Drivers
What’s a Driver?
•  Native Language Library
•  API that exposes methods to operate w/ MongoDB
•  Serialization and Deseria...
struct MsgHeader {
int32 messageLength; // total message size, including this
int32 requestID; // identifier for this mess...
struct OP_INSERT {
MsgHeader header; // standard message header
int32 flags; // bit vector - see below
cstring fullCollect...
struct OP_QUERY {
MsgHeader header; // standard message header
int32 flags; // bit vector of query options. See below for ...
How many drivers ?
•  A few
How many drivers?
•  13 officially supported drivers
–  Python
–  Java
–  C / C++ / C#
–  PHP
–  Node.js
–  Perl
–  Ruby
– ...
How many drivers?
•  Community Supported
–  Matlab
–  R
–  Go
–  Clojure
–  Dart
–  Erlang
–  Prolog
–  …
http://docs.mong...
Community vs Official Supported
Don’t take the RED PILL!
Things to consider
•  Official driver means:
–  We have dedicated resources to work on the driver
–  Constant delivery and ...
But most important
Use the best tool for the
problem!
Language Ecosystem
Python
•  Official Driver
–  pymongo
•  Frameworks | ODMs
–  mongoengine
–  minimongo
–  Manga
•  Alternative Drivers
–  As...
> pip install pymongo
//or
> easy_install pymongo
//using ipython
> ipython
>> from pymongo import MongoClient
>> mc = Mon...
Node.js
•  Official Driver
–  http://mongodb.github.io/node-mongodb-native/
•  ODM
–  Mongose
•  http://mongoosejs.com/
•  ...
> node
>> var MongoClient = require("mongodb").MongoClient
>> MongoClient.connect( "mongodb://nair.local:27017",
function(...
Java
•  Official Driver
–  http://api.mongodb.org/java/current/index.html
•  Multiple Frameworks
–  Morphya
–  DataNucleus ...
Clojure
(ns my.service.server
(:require [monger.core :as mg])
(:import [com.mongodb MongoOptions ServerAddress]))

;; localhost, d...
Go
•  Not officially supported driver!
•  mgo Library
–  http://labix.org/mgo
–  Really cool!
–  We use it internally for s...
Let’s get some code Running!
MongoDB Meta Driver Project
Meta Driver
•  http://docs.mongodb.org/meta-driver/latest/
•  Help new drivers to be built by the community
•  Basic struc...
Obrigado!
norberto@mongodb.com
Norberto Leite
@nleite
How Different are MongoDB Drivers
Upcoming SlideShare
Loading in …5
×

How Different are MongoDB Drivers

2,208 views

Published on

How many drivers for MongoDB are there? Which one is the best? How do they differ from one another? We are going to explore this and other questions with some code examples across a great deal languages

Published in: Technology
  • Be the first to comment

  • Be the first to like this

How Different are MongoDB Drivers

  1. 1. How different are MongoDB Drivers? SA, MongoDB Norberto Leite #mongobe
  2. 2. { "name":"Norberto Leite", "role":"Solutions Architect", "company":"MongoDB", "address": ["Barcelona,Spain”,”Brussels,Belgium”] "contact": "norberto@mongodb.com", "likes": { "beer":"Superbock", "software": ["Development","python", "go","databases"], "football":"FC Porto" } } Hi There!
  3. 3. Agenda •  MongoDB Drivers •  Community vs Official Supported •  General Considerations •  Examples •  Meta Driver Project
  4. 4. MongoDB Drivers
  5. 5. What’s a Driver? •  Native Language Library •  API that exposes methods to operate w/ MongoDB •  Serialization and Deserialization of native objects/ structures into BSON format –  http://bsonspec.org •  Handles the communication and pooling with server
  6. 6. struct MsgHeader { int32 messageLength; // total message size, including this int32 requestID; // identifier for this message int32 responseTo; // requestID from the original request // (used in reponses from db) int32 opCode; // request type - see table below } Driver Messages
  7. 7. struct OP_INSERT { MsgHeader header; // standard message header int32 flags; // bit vector - see below cstring fullCollectionName; // "dbname.collectionname" document* documents; // one or more documents to insert into the collection } Insert Message
  8. 8. struct OP_QUERY { MsgHeader header; // standard message header int32 flags; // bit vector of query options. See below for det cstring fullCollectionName ; // "dbname.collectionname" int32 numberToSkip; // number of documents to skip int32 numberToReturn; // number of documents to return // in the first OP_REPLY batch document query; // query object. See below for details. [ document returnFieldsSelector; ] // Optional. Selector indicating the fiel // to return. See below for details. } Query Message
  9. 9. How many drivers ? •  A few
  10. 10. How many drivers? •  13 officially supported drivers –  Python –  Java –  C / C++ / C# –  PHP –  Node.js –  Perl –  Ruby –  Scala –  … http://docs.mongodb.org/ecosystem/drivers/
  11. 11. How many drivers? •  Community Supported –  Matlab –  R –  Go –  Clojure –  Dart –  Erlang –  Prolog –  … http://docs.mongodb.org/ecosystem/drivers/community-supported-drivers/
  12. 12. Community vs Official Supported
  13. 13. Don’t take the RED PILL!
  14. 14. Things to consider •  Official driver means: –  We have dedicated resources to work on the driver –  Constant delivery and updated with server version –  Support includes fixes for drivers •  Some community drivers are also maintained by MongoDB engineers –  mongoengine –  motor –  …
  15. 15. But most important Use the best tool for the problem!
  16. 16. Language Ecosystem
  17. 17. Python •  Official Driver –  pymongo •  Frameworks | ODMs –  mongoengine –  minimongo –  Manga •  Alternative Drivers –  Asynchronous •  Motor •  TxMongo
  18. 18. > pip install pymongo //or > easy_install pymongo //using ipython > ipython >> from pymongo import MongoClient >> mc = MongoClient() Python
  19. 19. Node.js •  Official Driver –  http://mongodb.github.io/node-mongodb-native/ •  ODM –  Mongose •  http://mongoosejs.com/ •  Others –  Mongoskin –  Mongolia http://docs.mongodb.org/ecosystem/drivers/node-js/
  20. 20. > node >> var MongoClient = require("mongodb").MongoClient >> MongoClient.connect( "mongodb://nair.local:27017", function(err, db){ if(!err) {console.log("we are connected");} }); >> var col = db.collection("sample"); Node.js
  21. 21. Java •  Official Driver –  http://api.mongodb.org/java/current/index.html •  Multiple Frameworks –  Morphya –  DataNucleus JPA/JDO –  Jongo •  JVM Languages –  Scala –  Clojure –  Groovy
  22. 22. Clojure
  23. 23. (ns my.service.server (:require [monger.core :as mg]) (:import [com.mongodb MongoOptions ServerAddress])) ;; localhost, default port (mg/connect!) ;; set default database using set-db (mg/set-db! (mg/get-db "monger-test")) Clojure
  24. 24. Go •  Not officially supported driver! •  mgo Library –  http://labix.org/mgo –  Really cool! –  We use it internally for some projects •  Others –  gomongo –  go-mongo
  25. 25. Let’s get some code Running!
  26. 26. MongoDB Meta Driver Project
  27. 27. Meta Driver •  http://docs.mongodb.org/meta-driver/latest/ •  Help new drivers to be built by the community •  Basic structure and conventions documentation •  Beta Project–Under Development
  28. 28. Obrigado! norberto@mongodb.com Norberto Leite @nleite

×