SlideShare a Scribd company logo
STANDARDIZINGOURDRIVERSTHROUGHSPECS:
ALOOKATTHECRUDAPI
OPENINGTUESDAY,JUNE2ND
INSELECTCONFERENCEROOMS.
Jeremy Mikola
jmikola
What’sthedealwithspecs?
ACursoryIntroduction
SHAMELESSLYBORROWEDFROM…
MongoDBhasalotofdrivers…
   
           
   
DriversToday
APIs evolved over many years
Idiomatic for their language
Inconsistent with each other
Subtle behavioral differences
Our support team loves this!
Specifications
Authentication
SDAM, server selection
Wire protocol, write commands
User-facing APIs
CRUD, enumeration, $out
EndGoals
Consistency across drivers
Behavior and API
More intuitive documentation
Increased developer productivity
Guidance for third-party drivers
EndGoals(Continued)
Mitigate Parkinson’s law of triviality
AvailableonGitHub
Internal WIPs → Released Specs
See: mongodb/specifications
Mailing lists are still in vogue:
andmongodb-drivers mongodb-dev
CRUDSpecification
Standardizing Our Drivers Through Specifications: A Look at the CRUD API
Whatareweaddressing?
Collection-level read/write methods.
Variations in naming and semantics.
Inconsistent functionality and APIs.
DefaultBehaviors(ExhibitA)
//Updatesonedocument
db.things.update(
{"type":"human"},
{"$set":{"organic":true}}
);
//Removesallmatchingdocuments
db.things.remove(
{"type":"robot"}
);
OptionNames(ExhibitB)
//Updatesalldocuments
db.things.update(
{"type":"human"},
{"$set":{"organic":true}}
{"multi":true}
);
//Removesonematchingdocument
db.things.remove(
{"type":"robot"},
{"justOne":true}
);
MethodSignatures(ExhibitC)
//Accordingtothedocumentation
function(query,update,options){
//...
}
//Actualimplementation
function(query,update,upsert,multi){
if(typeof(upsert)==="object"){
//Unpackoptions...
}
//...
}
Legacy baggage with update()
CRUD
Create
Read
Update
Delete
insert()
find()
update()
remove()
ButWait…There’sMore!
CRUDCRADBOoMFaM
Create
Read
Update
Delete
Count
Replace
Aggregate
Distinct
Bulk, One or Many
Find and Modify
Standardizing Our Drivers Through Specifications: A Look at the CRUD API
Ourentirelyreasonableand
level-headedapproach…
BEARWITHME.
Terminology
Collection: class or interface representing a collection.
Spec defines methods to be implemented on this object.
Iterable: some iterable object or structure.
Cursor or cursor-like abstraction for reads.
Vector or array for write method arguments.
Operations
Methods to be implemented on the Collection object.
These have required and optional parameters.
Deviations
Spec is flexible with naming and option handling.
This permits idiomaticity. (real word)☜
NamingDeviations
“Root” words are non-negotiable.
batchSize, batch_size ʕ•ᴥ•ʔ
batchCount щ(゚Д゚щ)
maxTimeMS, maxTime ͡° ͜ʖ ͡°
maximumTime? (╯°□°)╯︵ ┻━┻
FindOptions, FindArgs ‫(ﺡ‬゚ヮ゚)ノ
QueryParams? (ノಠ益ಠ)ノ彡┻━┻
ordered, isOrdered ᕕ( ᐛ )ᕗ
OptionHandling
Required options are positional arguments.
For optional options, you have some options:
Named parameters
Dictionary or hash objects
Option classes (e.g. UpdateOptions)
May be consolidated, shared
Fluent builders for find(), aggregate()
Document when order of operations applies!
Whatwe’renotdoing
Method overloading.
Encapsulating params in “Model” classes.
Codifying inconsistent APIs for BC.
DivingintotheAPI
Chapter1:Reads
Querying
find(filter:Document,options:FindOptions):
Iterable<Document>;
filteris criteria (i.e. $querymeta operator).
Support other operators through options.
Iterable is obviously a cursor here.
FindOptions
allowPartialResults: Boolean
batchSize: Int32
comment: String
cursorType: CursorType
limit: Int32
maxTimeMS: Int64
modifiers: Document
noCursorTimeout: Boolean
oplogReplay: Boolean
projection: Document
skip: Int32
sort: Document
AbstractingInternalDetails
CursorTypeenum may be normal,
tailable, or tailable and awaitable.
Today’s wire protocol flags are
tomorrow’s command options.
Users shouldn’t care and
it’s not worth future API breaks.
OtherReadMethods
aggregate(pipeline:Document[],options:AggregateOptions):
Iterable<Document>;
count(filter:Document,options:CountOptions):
Int64;
distinct(fieldName:string,filter:Document,options:DistinctOptions):
Iterable<any>;
AggregateOptions
allowDiskUse: Boolean
batchSize: Int32
maxTimeMS: Int64
useCursor: Boolean
useCursordefault varies by server version.
May affect the kind of Iterable returned.
DivingintotheAPI
Chapter2:Writes
We’rebasically50%doneatthispoint…
WriteMethods
insertOne(document:Document):
InsertOneResult;
insertMany(Iterable<Document>documents,options:InsertManyOptions):
InsertManyResult;
deleteOne(filter:Document):
DeleteResult;
deleteMany(filter:Document):
DeleteResult;
One or many behavior is explicit and
facilitates self-documenting code.
Eliminates inconsistency between multiand justOne
defaults for update()and remove(), respectively.
insertMany()
insertManyis syntactic sugar
for bulkWrite()with inserts.
Spec doesn’t address legacy
batch OP_INSERToperations.
InsertManyOptions
ordered: Boolean
WriteMethods(Continued)
replaceOne(filter:Document,replacement:Document,options:UpdateOptions):
UpdateResult;
updateOne(filter:Document,update:Document,options:UpdateOptions):
UpdateResult;
updateMany(filter:Document,update:Document,options:UpdateOptions):
UpdateResult;
Same points about explicit,
self-documenting code apply.
Trivial to validate if replacement or
update documents contain operators.
UpdateOptions
upsert: Boolean
BulkWrites
bulkWrite(requests:WriteModel[],options:BulkWriteOptions):
BulkWriteResult;
Remember initializeOrderedBulkOp(),
or the really old fluent API from 2013?
WriteModel
Also, remember when we said we weren’t doing
“model” classes that encapsulate all arguments?
WriteModel
Models include required and optional (if any)
arguments from single write methods.
bulkWrite()’s requestsargument
allows users to specify all of their writes
at once and in a single method call.
Trivial to make a fluent API atop this,
although it’s not in the spec.
UpdateManyModel(f.e.)
filter: Document required
update: Document required
upsert: Boolean optional
BulkWriteOptions
ordered: Boolean
Basically the same thing as InsertManyOptions.
ResultClasses
Insert results may report driver-generated IDs
Delete results include counts
Update results include counts and
server-generated IDs from upserts
Bulk results aggregate all of the above
Results are optional for unacknowledged writes.
(e.g. Optional<BulkWriteResult>, isAcknowledgedboolean)
Since all fields within insert results are optional,
insertOne()and insertMany()may be void!
WriteErrors
Spec is flexible on how errors are reported
Mainly concerned that info is accessible
under consistent fields and names.
Doesn’t address merging errors
We have a bulk write spec for that
DivingintotheAPI
Chapter3:FindandModify
I’llkeepthisshort…
FindandModifyMethods
findOneAndDelete(
filter:Document,
options:FindOneAndDeleteOptions
):Document;
findOneAndReplace(
filter:Document,
replacement:Document,
options:FindOneAndReplaceOptions
):Document;
findOneAndUpdate(
filter:Document,
update:Document,
options:FindOneAndUpdateOptions
):Document;
Option classes contain only
the relevant command options.
PreemptiveQ&A
ReadPreferences?
Generally, queries on same collection
will use the same read preference.
Spec assumes it’s set on
client, database, or collection.
Per-operation read preferences are permitted;
the spec simply doesn’t define it.
WriteConcerns?
Everything we just said about read preferences…
findOne()etal.
Drivers are free to keep existing methods
and add new ones, too.
Please keep options and naming consistent.
Thanks!
FIN.
Questions?
ImageCredits
and
http://www.instructables.com/id/Egg-Cream/
Giphy Reaction Gifs
https://octodex.github.com/wheres-waldocat/

More Related Content

PPTX
javascript 1
osman do
 
PPTX
JavaScript Fundamentals & JQuery
Jamshid Hashimi
 
PPTX
Web programming
Leo Mark Villar
 
PPTX
1. java script language fundamentals
Rajiv Gupta
 
PPT
Learn javascript easy steps
prince Loffar
 
PPTX
Introduction to JavaScript Basics.
Hassan Ahmed Baig - Web Developer
 
PPT
Java script -23jan2015
Sasidhar Kothuru
 
PPTX
Javascript functions
Alaref Abushaala
 
javascript 1
osman do
 
JavaScript Fundamentals & JQuery
Jamshid Hashimi
 
Web programming
Leo Mark Villar
 
1. java script language fundamentals
Rajiv Gupta
 
Learn javascript easy steps
prince Loffar
 
Introduction to JavaScript Basics.
Hassan Ahmed Baig - Web Developer
 
Java script -23jan2015
Sasidhar Kothuru
 
Javascript functions
Alaref Abushaala
 

What's hot (20)

PPTX
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
Doug Jones
 
PPTX
Java script
Sadeek Mohammed
 
PPTX
Introduction to java script
DivyaKS12
 
PPTX
Java script
Shyam Khant
 
PPT
Java script final presentation
Adhoura Academy
 
PPT
Introduction to Javascript
Amit Tyagi
 
PPTX
FYBSC IT Web Programming Unit III Javascript
Arti Parab Academics
 
PDF
web2py:Web development like a boss
Francisco Ribeiro
 
PDF
Wt unit 2 ppts client side technology
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
PPTX
Client side scripting using Javascript
Bansari Shah
 
PPT
Java script
Soham Sengupta
 
PPTX
FYBSC IT Web Programming Unit IV PHP and MySQL
Arti Parab Academics
 
PPT
Scorware - Spring Introduction
vschiavoni
 
PPTX
Java script
Jay Patel
 
PPTX
Lab#1 - Front End Development
Walid Ashraf
 
PPT
Java Script ppt
Priya Goyal
 
PPT
Java script
ITz_1
 
PPT
Html JavaScript and CSS
Radhe Krishna Rajan
 
PPTX
Java script
Rajkiran Mummadi
 
PDF
Javascript
Rajavel Dhandabani
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
Doug Jones
 
Java script
Sadeek Mohammed
 
Introduction to java script
DivyaKS12
 
Java script
Shyam Khant
 
Java script final presentation
Adhoura Academy
 
Introduction to Javascript
Amit Tyagi
 
FYBSC IT Web Programming Unit III Javascript
Arti Parab Academics
 
web2py:Web development like a boss
Francisco Ribeiro
 
Wt unit 2 ppts client side technology
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Client side scripting using Javascript
Bansari Shah
 
Java script
Soham Sengupta
 
FYBSC IT Web Programming Unit IV PHP and MySQL
Arti Parab Academics
 
Scorware - Spring Introduction
vschiavoni
 
Java script
Jay Patel
 
Lab#1 - Front End Development
Walid Ashraf
 
Java Script ppt
Priya Goyal
 
Java script
ITz_1
 
Html JavaScript and CSS
Radhe Krishna Rajan
 
Java script
Rajkiran Mummadi
 
Javascript
Rajavel Dhandabani
 
Ad

Viewers also liked (10)

PDF
SOA & APIs: Fearless Lessons from the Field
CA API Management
 
PDF
From CRUD to Hypermedia APIs with Spring
Vladimir Tsukur
 
PDF
Cqrs api v2
Brandon Mueller
 
PDF
rest without put
Xiaojun REN
 
PDF
Cqrs api
Brandon Mueller
 
PPTX
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
reneechemel
 
PPTX
Web api crud operations
Eyal Vardi
 
PDF
Restful web services by Sreeni Inturi
Sreeni I
 
PDF
Restful Web Services
Angelin R
 
PPT
REST beyond CRUD
Paulo Gandra de Sousa
 
SOA & APIs: Fearless Lessons from the Field
CA API Management
 
From CRUD to Hypermedia APIs with Spring
Vladimir Tsukur
 
Cqrs api v2
Brandon Mueller
 
rest without put
Xiaojun REN
 
Cqrs api
Brandon Mueller
 
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
reneechemel
 
Web api crud operations
Eyal Vardi
 
Restful web services by Sreeni Inturi
Sreeni I
 
Restful Web Services
Angelin R
 
REST beyond CRUD
Paulo Gandra de Sousa
 
Ad

Similar to Standardizing Our Drivers Through Specifications: A Look at the CRUD API (20)

PPTX
Functional programming in TypeScript
binDebug WorkSpace
 
PPT
Building scalable and language independent java services using apache thrift
Talentica Software
 
PPT
Building scalable and language-independent Java services using Apache Thrift ...
IndicThreads
 
PDF
OORPT Dynamic Analysis
lienhard
 
PDF
Open source Technology
Amardeep Vishwakarma
 
PDF
BDD Testing Using Godog - Bangalore Golang Meetup # 32
OpenEBS
 
PDF
Making the Most of User Changes
ESUG
 
KEY
Maintaining Code
Kelly Bauer
 
PDF
Porting VisualWorks code to Pharo
ESUG
 
PDF
Throwing Laravel into your Legacy App™
Joe Ferguson
 
PPTX
The pragmatic programmer
LeylimYaln
 
PPT
UNIT 3.1 INTRODUCTON TO IDA.ppt
ManjuAppukuttan2
 
PDF
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
Felipe Prado
 
PPTX
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
Dave Bost
 
PDF
Working Effectively With Legacy Perl Code
erikmsp
 
PPTX
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
Maarten Balliauw
 
PDF
Measuring Your Code
Nate Abele
 
PDF
Measuring Your Code 2.0
Nate Abele
 
PPTX
Productionalizing ML : Real Experience
Ihor Bobak
 
Functional programming in TypeScript
binDebug WorkSpace
 
Building scalable and language independent java services using apache thrift
Talentica Software
 
Building scalable and language-independent Java services using Apache Thrift ...
IndicThreads
 
OORPT Dynamic Analysis
lienhard
 
Open source Technology
Amardeep Vishwakarma
 
BDD Testing Using Godog - Bangalore Golang Meetup # 32
OpenEBS
 
Making the Most of User Changes
ESUG
 
Maintaining Code
Kelly Bauer
 
Porting VisualWorks code to Pharo
ESUG
 
Throwing Laravel into your Legacy App™
Joe Ferguson
 
The pragmatic programmer
LeylimYaln
 
UNIT 3.1 INTRODUCTON TO IDA.ppt
ManjuAppukuttan2
 
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
Felipe Prado
 
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
Dave Bost
 
Working Effectively With Legacy Perl Code
erikmsp
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
Maarten Balliauw
 
Measuring Your Code
Nate Abele
 
Measuring Your Code 2.0
Nate Abele
 
Productionalizing ML : Real Experience
Ihor Bobak
 

More from MongoDB (20)

PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
PDF
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
PDF
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB
 
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB
 
PDF
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB
 
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB
 
PDF
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB
 
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
PDF
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB
 

Recently uploaded (20)

PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Doc9.....................................
SofiaCollazos
 
The Future of Artificial Intelligence (AI)
Mukul
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 

Standardizing Our Drivers Through Specifications: A Look at the CRUD API