SlideShare a Scribd company logo
#MDBlocal
MongoDB Stitch Introduction
Drew DiPalma, Product Manager
#MDBlocal
When building, you need to…
1. Safely and easily access data
2. Integrate with key services
3. Scalably serve requests
#MDBlocal
MongoDB Query Language + Native DriversIntegrated Rules
Functions3rd Party Services
Native SDKs (JavaScript, Android, iOS)
Rest-like API
#MDBlocal
Integrated services and
Functions for complex,
connection logic
Native SDKs for Android,
JS, and iOS clients
Direct Database
Access
#MDBlocal
How requests work…
1. Application request is made
1
#MDBlocal
How requests work…
1. Application request is made
2. Stitch parses and applies rules
2
#MDBlocal
How requests work…
1. Application request is made
2. Stitch parses and applies rules
3. Stitch orchestrates DB + Services
3
3
#MDBlocal
How requests work…
1. Application request is made
2. Stitch parses and applies rules
3. Stitch orchestrates DB + Services
4. Stitch aggregates and applies rules
4
#MDBlocal
How requests work…
1. Application request is made
2. Stitch parses and applies rules
3. Stitch orchestrates DB + Services
4. Stitch aggregates and applies rules
5. Client receives results 5
const stitch = require('mongodb-stitch');
let client, mongodb, coll, users;
stitch.StitchClientFactory
.create('APP-ID')
.then(stitchClient => {
client = stitchClient;
mongodb = client.service('mongodb', 'mongodb-atlas');
coll = mongodb.db('Demo').collection(’Users');
});
MongoDB Services Functions
Stitch Concepts
client.login().then(() => {
// You can use client.authenticate() to access other auth providers
client.authenticate('providerType', {options})
// Providers include:
// - Anonymous
// - Email/Password
// - Facebook
// - Google
// - API Keys
// - Custom (signed JWT)
MongoDB Services Functions
Stitch Concepts
client.login().then(() => {
coll.find({'city': 'Seattle'}).execute().then(docs => {
users = docs;
});
});
// Or execute almost any find/aggregate command
coll.find({'city': 'Seattle'})
.aggregate([…])
.count(…)
.deleteMany(…)
.deleteOne(…)
.insertMany(…)
.insertOne(…)
.updateMany(…)
.updateOne(…)
MongoDB Services Functions
Stitch Concepts
const twilioService = client.service('twilio', 'twilioService')
twilioService.send('+120155555553', '+12018675309', message)
const sesService = client.service('ses', 'sesService')
sesService.send(fromEmail, toEmail, message)
const s3Service = client.service('s3', 's3Service')
s3Service.put(bucket, key, acl, contentType)
MongoDB Services Functions
Stitch Concepts
#MDBlocal
• Scalable, hosted JavaScript functions
• Written using ECMAScript 5
• Easily incorporate application context
- context.values
- context.services
- context.user
- context.request
- context.functions
- context.utils
Stitch Functions
client.executeFunction('sendWeather', 'Seattle');
MongoDB Services Functions
Stitch Concepts
client.executeFunction('sendWeather', 'Seattle');
MongoDB Services Functions
Stitch Concepts
//Function sendweather
exports = function(city) {
var mongodb = context.services.get("mongodb-atlas");
var UserColl = mongodb.db("StitchDemo").collection("Users");
var twilio = context.services.get("twilio");
var weather = context.services.get("weatherAPI");
var users = UserColl.find({"city": city});
var forecast = weather.get({context.values.get("weatherURL") + city});
var statuses = [];
for(var i in users){
statuses.push(twilio.send(context.values.get("twilioPhone")), users[i].Phone, forecast);
}
return statuses;
}
#MDBlocal
• Control DB/Service/Function access
• Fine-grained data access controls
• Define with simple JSON or link to
functions
• Associate with user profile, MDB Data,
or external info
Declarative Access Controls
#MDBlocal
Atlas
Customer Account Data
{
"owner_id": … ,
"balance": … ,
"transactions": {…},
"user_profile": {….}
}Bank
Teller
Analys
t
Custome
r
Roles,Permissions,andSecurity
Application
Reporting Data Mart
User Profile:
“I need to access my account”
Role Based:
“I need to lookup transactions
without seeing personal information”
Aggregate Only:
“I need to understand the bank’s total
cash flow”
#MDBlocal
Bank
Teller
Analys
t
Custome
r
Atlas
Customer Account Data
{
"owner_id": … ,
"balance": … ,
"transactions": {…},
"user_profile": {….}
}
Stitch
user_profile
(Read Rule)
{”owner_id": ”%%user.id"}
balance/transactions
(Read Rules)
{
”%or": [
{”owner_id": ”%%user.id"},
{"%%true": { "%function":
{ "name": ”isTeller",
"args": []
}
]
}
{
"user_id": … ,
"balance": … ,
"transactions":
{…},
"user_profile": {….}
}
#MDBlocal
Stitch
user_profile
(Read Rule)
{”owner_id": ”%%user.id"}
balance/transactions
(Read Rules)
{
”%or": [
{”owner_id": ”%%user.id"},
{"%%true": { "%function":
{ "name": ”isTeller",
"args": []
}
]
}
Bank
Teller
Analys
t
Custome
r
Atlas
Customer Account Data
{
"owner_id": … ,
"balance": … ,
"transactions": {…},
"user_profile": {….}
}
{
"user_id": … ,
"balance": … ,
"transactions": {…}
}
#MDBlocal
Stitch
user_profile
(Read Rule)
{”owner_id": ”%%user.id"}
balance/transactions
(Read Rules)
{
”%or": [
{”owner_id": ”%%user.id"},
{"%%true": { "%pipeline":
{ "name": "CheckAuth",
"args": { "AuthType": "server",
"UserAuth": "%%user.type"}
}
]
}
Stitch
user_profile
(Read Rule)
{”owner_id": ”%%user.id"}
balance/transactions
(Read Rules)
{
”%or": [
{”owner_id": ”%%user.id"},
{"%%true": { "%function":
{ "name": ”isTeller",
"args": []
}
]
}
Bank
Teller
Analys
t
Custome
r
{Aggregated
Data}
Stitch
Function for Analysis
{
"%%true": { "%function":
{ "name": ”isAnalyst",
"args": []}
}
Atlas
Customer Account Data
{
"owner_id": … ,
"balance": … ,
"transactions": {…},
"user_profile": {….}
}
#MDBlocal
Stitch in Action
#MDBlocal
Amazon S3 MongoDB
Atlas
twilio Amazon
Rekognition
2FA Access Control with Stitch
Secure IoT Client
• Bi-directional communication
• Secure com via API key auth
• Device access to DB,
functions and Services
Complex, Scalable Backend
• Deeply integrated services
• Coordination logic via
Functions
• Security through Auth + Rules
• Elastic scale
#MDBlocal
MongoDB
Atlas
Twilio
Amazon
Rekognition
{key: “*”}
capture_image()
{match: Drew,
Prob: 99.0%}
{user: “Drew”,
Ph#: 555-1212}
{user: Drew,
OTP: 135}
{user: Drew,
OTP: 135}
Ph#: 555-1212
{Ph#: 555-1212,
OTP: 135}
{OTP: 135}
{OTP: 135}
Amazon S3
process:
1. User requests photo + SMS
entry
2. Stitch asks ElectricImp for
photo
3. EI takes photo, sends to
Stitch
4. Stitch sends the photo to
AWS S3 and Rekognition
5. Rekognition sends image
analysis
6. Stitch queries Atlas for User
7. Stitch generates an entry
code, writes log, sends text
via Twilio
8. User enters code with key
pad, ElectricImp sends to
Stitch
9. Stitch checks code against
logs
10. If the code is valid, the Stitch
sends Electric Imp a message
to unlock.
#MDBlocal
Stitch Demo
#MDBlocal
Add Features
• Take your app to a
new platform
• Build a better
permissions
system or a
separate admin
portal
• Add additional
authentication
providers
Expose Data
• Provide an API for
safe, internal data
access
• Build more precise
permissions
system
• Create a real-time
dashboard with
authentication and
security built-in
Integrate Services
• Integrate with any
service or API with
minimal code
• Consume/action on
data in real time
with webhooks
• Communicate with
data using text,
e-mail, etc.
Complete
Backend
• Build faster without
boilerplate code
• Easily span multiple
platforms
• Scale at a moments
notice
• Single, simplified
point to manage
infrastructure/logic
#MDBlocal
• $1 per GB of data transferred from Stitch to client/service
• 25 GB Free per month
• Data transfer to Atlas is free
Pricing
#MDBlocal
xx
Everywher
e
Expand Regional footprint
Available on-premise
Bring any MongoDB
Realtime
Change Streams
driven
Event-based functions
Improve
Dev
App Import/Export Tools
User/Log Management
Rules Usability
What’s Next?
#MDBlocal
• Check out our hands-on lab: 12:50PM in the Sound Room
• Try out Stitch – stitch.mongodb.com
• Check out SDKs and examples
• Code at github.com/MongodbStitch
• Docs at docs.mongodb.com/stitch
• Build the Dashboard or Weather IoT apps in our Tutorials section
• Ask Questions or let us know what you’re building through Intercom
What Now?
#MDBlocal
THANK YOU
FOR JOINING!

More Related Content

What's hot (19)

PDF
CQRS and Event Sourcing with MongoDB and PHP
Davide Bellettini
 
PPTX
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
MongoDB
 
PPTX
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB
 
PPTX
A serverless IoT story from design to production and monitoring
CodeValue
 
PPTX
NGSIv2 Overview for Developers That Already Know NGSIv1
Fermin Galan
 
ODP
Event sourcing with Eventuate
Knoldus Inc.
 
PPT
Integrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Mark Maslyn
 
PDF
Amazon Cognito + Lambda + S3 + IAM
Andriy Samilyak
 
PDF
IBM Index Conference - 10 steps to build token based API Security
Senthilkumar Gopal
 
PPTX
MongoDB Stich Overview
MongoDB
 
PPTX
Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...
MongoDB
 
PPTX
Intro to Firebase Realtime Database and Authentication
kristinferrier
 
PDF
Async
jonathanfmills
 
PDF
MongoDB .local Toronto 2019: MongoDB Atlas Search Deep Dive
MongoDB
 
PPTX
Http session (Java)
Mrittunjoy Das
 
PDF
NodeJS: the good parts? A skeptic’s view (jax jax2013)
Chris Richardson
 
PDF
MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...
MongoDB
 
PPTX
NGSIv2 Overview for Developers That Already Know NGSIv1 20180716
Fermin Galan
 
PDF
Events, Picos, and Microservices
Phil Windley
 
CQRS and Event Sourcing with MongoDB and PHP
Davide Bellettini
 
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
MongoDB
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB
 
A serverless IoT story from design to production and monitoring
CodeValue
 
NGSIv2 Overview for Developers That Already Know NGSIv1
Fermin Galan
 
Event sourcing with Eventuate
Knoldus Inc.
 
Integrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Mark Maslyn
 
Amazon Cognito + Lambda + S3 + IAM
Andriy Samilyak
 
IBM Index Conference - 10 steps to build token based API Security
Senthilkumar Gopal
 
MongoDB Stich Overview
MongoDB
 
Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...
MongoDB
 
Intro to Firebase Realtime Database and Authentication
kristinferrier
 
MongoDB .local Toronto 2019: MongoDB Atlas Search Deep Dive
MongoDB
 
Http session (Java)
Mrittunjoy Das
 
NodeJS: the good parts? A skeptic’s view (jax jax2013)
Chris Richardson
 
MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...
MongoDB
 
NGSIv2 Overview for Developers That Already Know NGSIv1 20180716
Fermin Galan
 
Events, Picos, and Microservices
Phil Windley
 

Similar to Building Your First App with MongoDB Stitch (20)

PPTX
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 
PPTX
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
MongoDB
 
PPTX
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB
 
PDF
Faites évoluer votre accès aux données avec MongoDB Stitch
MongoDB
 
PDF
MongoDB Stitch Introduction
MongoDB
 
PPTX
Introducing Stitch
MongoDB
 
PDF
Introducing MongoDB Stitch, Backend-as-a-Service from MongoDB
MongoDB
 
PDF
Metaverse and Digital Twins on Enterprise-Public.pdf
湯米吳 Tommy Wu
 
PPTX
MongoDB.local Austin 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch A...
MongoDB
 
PPTX
Ibm xamarin gtruty
Ron Favali
 
PPTX
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
MongoDB
 
PDF
Medium TechTalk — iOS
jimmyatmedium
 
PDF
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB
 
PDF
MongoDB Mobile
MongoDB
 
PDF
Presenting Data – An Alternative to the View Control
Teamstudio
 
PPTX
Implementing Your Full Stack App with MongoDB Stitch (Tutorial)
MongoDB
 
PDF
Frontend APIs powering fast paced product iterations
Karthik Ramgopal
 
PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
PPTX
Grokking Engineering - Data Analytics Infrastructure at Viki - Huy Nguyen
Huy Nguyen
 
PDF
Iot 1906 - approaches for building applications with the IBM IoT cloud
PeterNiblett
 
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
MongoDB
 
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB
 
Faites évoluer votre accès aux données avec MongoDB Stitch
MongoDB
 
MongoDB Stitch Introduction
MongoDB
 
Introducing Stitch
MongoDB
 
Introducing MongoDB Stitch, Backend-as-a-Service from MongoDB
MongoDB
 
Metaverse and Digital Twins on Enterprise-Public.pdf
湯米吳 Tommy Wu
 
MongoDB.local Austin 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch A...
MongoDB
 
Ibm xamarin gtruty
Ron Favali
 
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
MongoDB
 
Medium TechTalk — iOS
jimmyatmedium
 
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB
 
MongoDB Mobile
MongoDB
 
Presenting Data – An Alternative to the View Control
Teamstudio
 
Implementing Your Full Stack App with MongoDB Stitch (Tutorial)
MongoDB
 
Frontend APIs powering fast paced product iterations
Karthik Ramgopal
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
Grokking Engineering - Data Analytics Infrastructure at Viki - Huy Nguyen
Huy Nguyen
 
Iot 1906 - approaches for building applications with the IBM IoT cloud
PeterNiblett
 
Ad

More from MongoDB (20)

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
 
PDF
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
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
 
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
MongoDB
 
Ad

Recently uploaded (20)

PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Digital Circuits, important subject in CS
contactparinay1
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 

Building Your First App with MongoDB Stitch

  • 2. #MDBlocal When building, you need to… 1. Safely and easily access data 2. Integrate with key services 3. Scalably serve requests
  • 3. #MDBlocal MongoDB Query Language + Native DriversIntegrated Rules Functions3rd Party Services Native SDKs (JavaScript, Android, iOS) Rest-like API
  • 4. #MDBlocal Integrated services and Functions for complex, connection logic Native SDKs for Android, JS, and iOS clients Direct Database Access
  • 5. #MDBlocal How requests work… 1. Application request is made 1
  • 6. #MDBlocal How requests work… 1. Application request is made 2. Stitch parses and applies rules 2
  • 7. #MDBlocal How requests work… 1. Application request is made 2. Stitch parses and applies rules 3. Stitch orchestrates DB + Services 3 3
  • 8. #MDBlocal How requests work… 1. Application request is made 2. Stitch parses and applies rules 3. Stitch orchestrates DB + Services 4. Stitch aggregates and applies rules 4
  • 9. #MDBlocal How requests work… 1. Application request is made 2. Stitch parses and applies rules 3. Stitch orchestrates DB + Services 4. Stitch aggregates and applies rules 5. Client receives results 5
  • 10. const stitch = require('mongodb-stitch'); let client, mongodb, coll, users; stitch.StitchClientFactory .create('APP-ID') .then(stitchClient => { client = stitchClient; mongodb = client.service('mongodb', 'mongodb-atlas'); coll = mongodb.db('Demo').collection(’Users'); }); MongoDB Services Functions Stitch Concepts
  • 11. client.login().then(() => { // You can use client.authenticate() to access other auth providers client.authenticate('providerType', {options}) // Providers include: // - Anonymous // - Email/Password // - Facebook // - Google // - API Keys // - Custom (signed JWT) MongoDB Services Functions Stitch Concepts
  • 12. client.login().then(() => { coll.find({'city': 'Seattle'}).execute().then(docs => { users = docs; }); }); // Or execute almost any find/aggregate command coll.find({'city': 'Seattle'}) .aggregate([…]) .count(…) .deleteMany(…) .deleteOne(…) .insertMany(…) .insertOne(…) .updateMany(…) .updateOne(…) MongoDB Services Functions Stitch Concepts
  • 13. const twilioService = client.service('twilio', 'twilioService') twilioService.send('+120155555553', '+12018675309', message) const sesService = client.service('ses', 'sesService') sesService.send(fromEmail, toEmail, message) const s3Service = client.service('s3', 's3Service') s3Service.put(bucket, key, acl, contentType) MongoDB Services Functions Stitch Concepts
  • 14. #MDBlocal • Scalable, hosted JavaScript functions • Written using ECMAScript 5 • Easily incorporate application context - context.values - context.services - context.user - context.request - context.functions - context.utils Stitch Functions
  • 16. client.executeFunction('sendWeather', 'Seattle'); MongoDB Services Functions Stitch Concepts //Function sendweather exports = function(city) { var mongodb = context.services.get("mongodb-atlas"); var UserColl = mongodb.db("StitchDemo").collection("Users"); var twilio = context.services.get("twilio"); var weather = context.services.get("weatherAPI"); var users = UserColl.find({"city": city}); var forecast = weather.get({context.values.get("weatherURL") + city}); var statuses = []; for(var i in users){ statuses.push(twilio.send(context.values.get("twilioPhone")), users[i].Phone, forecast); } return statuses; }
  • 17. #MDBlocal • Control DB/Service/Function access • Fine-grained data access controls • Define with simple JSON or link to functions • Associate with user profile, MDB Data, or external info Declarative Access Controls
  • 18. #MDBlocal Atlas Customer Account Data { "owner_id": … , "balance": … , "transactions": {…}, "user_profile": {….} }Bank Teller Analys t Custome r Roles,Permissions,andSecurity Application Reporting Data Mart User Profile: “I need to access my account” Role Based: “I need to lookup transactions without seeing personal information” Aggregate Only: “I need to understand the bank’s total cash flow”
  • 19. #MDBlocal Bank Teller Analys t Custome r Atlas Customer Account Data { "owner_id": … , "balance": … , "transactions": {…}, "user_profile": {….} } Stitch user_profile (Read Rule) {”owner_id": ”%%user.id"} balance/transactions (Read Rules) { ”%or": [ {”owner_id": ”%%user.id"}, {"%%true": { "%function": { "name": ”isTeller", "args": [] } ] } { "user_id": … , "balance": … , "transactions": {…}, "user_profile": {….} }
  • 20. #MDBlocal Stitch user_profile (Read Rule) {”owner_id": ”%%user.id"} balance/transactions (Read Rules) { ”%or": [ {”owner_id": ”%%user.id"}, {"%%true": { "%function": { "name": ”isTeller", "args": [] } ] } Bank Teller Analys t Custome r Atlas Customer Account Data { "owner_id": … , "balance": … , "transactions": {…}, "user_profile": {….} } { "user_id": … , "balance": … , "transactions": {…} }
  • 21. #MDBlocal Stitch user_profile (Read Rule) {”owner_id": ”%%user.id"} balance/transactions (Read Rules) { ”%or": [ {”owner_id": ”%%user.id"}, {"%%true": { "%pipeline": { "name": "CheckAuth", "args": { "AuthType": "server", "UserAuth": "%%user.type"} } ] } Stitch user_profile (Read Rule) {”owner_id": ”%%user.id"} balance/transactions (Read Rules) { ”%or": [ {”owner_id": ”%%user.id"}, {"%%true": { "%function": { "name": ”isTeller", "args": [] } ] } Bank Teller Analys t Custome r {Aggregated Data} Stitch Function for Analysis { "%%true": { "%function": { "name": ”isAnalyst", "args": []} } Atlas Customer Account Data { "owner_id": … , "balance": … , "transactions": {…}, "user_profile": {….} }
  • 23. #MDBlocal Amazon S3 MongoDB Atlas twilio Amazon Rekognition 2FA Access Control with Stitch Secure IoT Client • Bi-directional communication • Secure com via API key auth • Device access to DB, functions and Services Complex, Scalable Backend • Deeply integrated services • Coordination logic via Functions • Security through Auth + Rules • Elastic scale
  • 24. #MDBlocal MongoDB Atlas Twilio Amazon Rekognition {key: “*”} capture_image() {match: Drew, Prob: 99.0%} {user: “Drew”, Ph#: 555-1212} {user: Drew, OTP: 135} {user: Drew, OTP: 135} Ph#: 555-1212 {Ph#: 555-1212, OTP: 135} {OTP: 135} {OTP: 135} Amazon S3 process: 1. User requests photo + SMS entry 2. Stitch asks ElectricImp for photo 3. EI takes photo, sends to Stitch 4. Stitch sends the photo to AWS S3 and Rekognition 5. Rekognition sends image analysis 6. Stitch queries Atlas for User 7. Stitch generates an entry code, writes log, sends text via Twilio 8. User enters code with key pad, ElectricImp sends to Stitch 9. Stitch checks code against logs 10. If the code is valid, the Stitch sends Electric Imp a message to unlock.
  • 26. #MDBlocal Add Features • Take your app to a new platform • Build a better permissions system or a separate admin portal • Add additional authentication providers Expose Data • Provide an API for safe, internal data access • Build more precise permissions system • Create a real-time dashboard with authentication and security built-in Integrate Services • Integrate with any service or API with minimal code • Consume/action on data in real time with webhooks • Communicate with data using text, e-mail, etc. Complete Backend • Build faster without boilerplate code • Easily span multiple platforms • Scale at a moments notice • Single, simplified point to manage infrastructure/logic
  • 27. #MDBlocal • $1 per GB of data transferred from Stitch to client/service • 25 GB Free per month • Data transfer to Atlas is free Pricing
  • 28. #MDBlocal xx Everywher e Expand Regional footprint Available on-premise Bring any MongoDB Realtime Change Streams driven Event-based functions Improve Dev App Import/Export Tools User/Log Management Rules Usability What’s Next?
  • 29. #MDBlocal • Check out our hands-on lab: 12:50PM in the Sound Room • Try out Stitch – stitch.mongodb.com • Check out SDKs and examples • Code at github.com/MongodbStitch • Docs at docs.mongodb.com/stitch • Build the Dashboard or Weather IoT apps in our Tutorials section • Ask Questions or let us know what you’re building through Intercom What Now?