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
PPTX
JavaScript Fundamentals & JQuery
PPTX
Web programming
PPTX
1. java script language fundamentals
PPT
Learn javascript easy steps
PPTX
Introduction to JavaScript Basics.
PPT
Java script -23jan2015
PPTX
Javascript functions
javascript 1
JavaScript Fundamentals & JQuery
Web programming
1. java script language fundamentals
Learn javascript easy steps
Introduction to JavaScript Basics.
Java script -23jan2015
Javascript functions

What's hot (20)

PPTX
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
PPTX
Java script
PPTX
Introduction to java script
PPTX
Java script
PPT
Java script final presentation
PPT
Introduction to Javascript
PPTX
FYBSC IT Web Programming Unit III Javascript
PDF
web2py:Web development like a boss
PDF
Wt unit 2 ppts client side technology
PPTX
Client side scripting using Javascript
PPT
Java script
PPTX
FYBSC IT Web Programming Unit IV PHP and MySQL
PPT
Scorware - Spring Introduction
PPTX
Java script
PPTX
Lab#1 - Front End Development
PPT
Java Script ppt
PPT
Java script
PPT
Html JavaScript and CSS
PPTX
Java script
PDF
Javascript
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
Java script
Introduction to java script
Java script
Java script final presentation
Introduction to Javascript
FYBSC IT Web Programming Unit III Javascript
web2py:Web development like a boss
Wt unit 2 ppts client side technology
Client side scripting using Javascript
Java script
FYBSC IT Web Programming Unit IV PHP and MySQL
Scorware - Spring Introduction
Java script
Lab#1 - Front End Development
Java Script ppt
Java script
Html JavaScript and CSS
Java script
Javascript
Ad

Viewers also liked (10)

PDF
SOA & APIs: Fearless Lessons from the Field
PDF
From CRUD to Hypermedia APIs with Spring
PDF
Cqrs api v2
PDF
rest without put
PDF
Cqrs api
PPTX
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
PPTX
Web api crud operations
PDF
Restful web services by Sreeni Inturi
PDF
Restful Web Services
PPT
REST beyond CRUD
SOA & APIs: Fearless Lessons from the Field
From CRUD to Hypermedia APIs with Spring
Cqrs api v2
rest without put
Cqrs api
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
Web api crud operations
Restful web services by Sreeni Inturi
Restful Web Services
REST beyond CRUD
Ad

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

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

More from MongoDB (20)

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

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
A Presentation on Artificial Intelligence
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
MYSQL Presentation for SQL database connectivity
Mobile App Security Testing_ A Comprehensive Guide.pdf
Encapsulation theory and applications.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Advanced methodologies resolving dimensionality complications for autism neur...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?
Per capita expenditure prediction using model stacking based on satellite ima...
A Presentation on Artificial Intelligence
Understanding_Digital_Forensics_Presentation.pptx
Empathic Computing: Creating Shared Understanding
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

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