SlideShare a Scribd company logo
Evolving your Data Access with MongoDB Stitch
Evolving Data Access
with MongoDB Stitch
Pavel Duchovny – Sr. Technical Services Engineer,
MongoDB
Rendering
Data
App ServerDatabase IoT DevicesPhone
Browser
Logic
CRUD Email
QueuesAccess Control
Payments
State
Sign On
Service
Coordination
Image
Processing
Applications are evolving
State/Logic
State
Logic
Rendering
Data
Database IoT DevicesPhone
Browser
State
Logic
Email
Queues
State
Sign On
Access Control
Service
Coordination
Image
Processin
g
Payments
Applications are evolving
CRUD
How is development evolving?
Application are living in more locations:
• 48% of apps have backends deployed to a public cloud
• 58% of apps are now developed for multiple platforms
More is expected of development:
• 64% of developers identified as full-stack (2017)
Too much time is spent on maintainence
•41% of time spent maintaining
•39% on new projects
Deploy and scale your application seamlessly
Write straightforward, standard code
Build simple, secure integrations
Presentation
UI Components
UI Process Components
Business
Business
Workflow
Business
Components
Business
Entities
Application Facade
Data
Data Access
Components
Data Helper
Utilities
Server
Agents
Data Sources Services
Users
External
Systems
Service
Interface
CrossCutting
Security
OperationalManagement
Communication
Traditional Applications….
• Contain many, separate layers
• Each layer is separate code, infrastructure
• Connecting/Maintaining layers is lots of work
Building an Application with Stitch
Security
&
Auth
Integration
Business Logic
Data Access
Hosting
Traditional Applications….
• Contain many, separate layers
• Each layer is separate code, infrastructure
• Connecting/Maintaining layers is lots of work
Building an Application with Stitch
Building applications with Stitch....
• No infrastructure to scale/patch/manage
• Simplified service integrations
• Easy to configure security
• Hosted, serverless business logic
Presentatio
n
UI Components
UI Process Components
Business
Business
Workflow
Business
Components
Business
Entities
Application Facade
Data
Data Access
Components
Data Helper
Utilities
Server
Agents
Data Sources Services
Users
External
Systems
Stitch is comprised of 4 services –
QueryAnywhere
Simple, streamlined syntax
for data access, robust
access rules, hosting
included
Build full apps for iOS,
Android, Web, and IoT
Functions
Integrate server-side logic +
microservices + cloud
services
Power apps with Server-side
logic, or enable Data as a
Service with custom APIs.
Triggers
Real-time notifications let your
application functions react in
response to database changes
App responds immediately to
change
Mobile Sync
Automatically synchronizes
data between documents
held locally in MongoDB
Mobile and your backend
database
(Beta)
Stitch QueryAnywhere
MongoDB Query Language + Native DriversIntegrated Rules
Functions3rd Party Services
Native SDKs (JavaScript, Android, iOS)
Rest API
Stitch QueryAnywhere
Request
User
Login
JWT
Filters
Roles
Rules
Stitch
Request
ResultsUser-specific
Results
Requests in Stitch
{
"userid":"101",
"name": "Bernice Herrera",
"employeeId": 53164957,
"zip": 2082,
"position": "IT Manager",
"manager": "Ralph McBride",
"hiringDate": ISODate("2017-05-02"),
"employeeSource": "website ads",
"salary": 205000,
"gender": "female",
"dob": ISODate("1972-10-02"),
"citizenship": "Australia",
"email": "bernice.herrera@example.com",
"empStatus": "active"
}
Sensitive
Information
Example: Employee Data
User
db.collection.find()
(plus user info)
db.collection.find({"empStatus": "active"})
[{
userid: "101"
name: …,
salary: …,
empStatus:"active"
},{
userid: "404"
name: …,
salary: …,
empStatus: "terminated",
}]
Results
{
"name": "ActiveOnly",
"apply_when": {"%%true" : true},
"query": {"empStatus":"active"}
}
Filters contain an apply_when and a
Query which is appended to a request
[{
userid: "101"
name: …,
salary: …,
empStatus:"active"
}]
Filters
[{ userid: "101"
name: …
salary: …
empStatus: "active"},
{ userid: "202"
name: …
salary: …
empStatus:"active"
}]
Roles are defined by Match statements,
evaluated per document, and assign a set of
Rules per document
User
{name: "OwnData",
apply_when: {"userid":"%%user.id"},
fields: {…}
}
[{ userid: "101"
name: …
salary: …
empStatus: "active"},
{ userid: "202"
name: …
salary: …
empStatus:"active"
}]
userid: "101"
Roles : OwnData
User
Each Role has a set of matching Rules that
define read and write access at the field-level
[{ userid: "101"
name: …
salary: …
empStatus: "active"},
{ userid: "202"
name: …
salary: …
empStatus:"active"
}]
[{ name: …
salary: …},
{ userid: "202"
name: …
salary: …
empStatus:"active"
}]
Rules : OwnData
"fields": {
"name" :{ "read": true},
"salary":{"read": true}
},
"additional_fields": {
"read": false,
"write": false
}
userid: "101"
Roles are defined by Match statements,
evaluated per document, and assign a set of
Rules per document
User
{name: "Everyone",
apply_when: {"%%true":true},
fields: {…}
}
[{ name: …
salary: …},
{ userid: "202"
name: …
salary: …
empStatus:"active"
}]
[{ name: …
salary: …},
{ userid: "202"
name: …
salary: …
empStatus:"active"
}]
userid: "101"
Roles : Everyone
User
Each Role has a set of matching Rules that
define read and write access at the field-level
[{
name: …
salary: …},
{ userid: "202"
name: …
salary: …
empStatus:"active"
}]
[{
name:…
salary: …
},{
name: …
}]
"fields": {
"name" :{ "read": true},
},
"additional_fields": {
"read": false,
"write": false
}
userid: "101"
Rules : Everyone
OwnData
Everyone
{
userid: "202"
name: …
salary: …
empStatus: "active"
}
{
userid: "101"
name: …
salary: …
empStatus: "active"
}
{
name: …
salary: …
}
{
name: …
}
Data Access
{
"filters": [{
"name": "ActiveOnly",
"apply_when": {"%%true" : true},
"query": {"empStatus":"active"}
}, … ],
"roles": [{
name: "OwnData"
apply_when: {"userid":"%%user.id"}
"fields": {
"name": {"read": true},
"salary": {"read": true}}
},
"additional fields": {
"read": false,
"write": false
}}, … ],
"schema": {…}
}
Filters
Roles
Rules
Schema
Rules Structure
schema: {
bsonType: "object",
required: ["userid", "email", "name"],
properties: {
userid: {
bsonType: "objectid",
description: "The ID of the Stitch user"
},
email: {
bsonType: "string",
description: "must be a string and is required"
},
name: {
bsonType: "string",
description: "must be a string and is required"
}
}
JSON Schema
schema: {
bsonType: "object",
required: ["userid", "email", "name"],
properties: {
userid: {
bsonType: "objectid",
description: "The ID of the Stitch user"
},
email: {
bsonType: "string",
validate: {"%%true": {
"%function": {
"name": "isValid",
"arguments": ["%%user", "%%this"]}
}},
description: "must be a string and is not required"
},
name: {
bsonType: "bool",
description: "True if the data is a secret"
}
[...]
Schema Validation
#MDBlocal
const stitchClient = stitch.initializeDefaultAppClient('myApp');
// Connect to a MongoDB Atlas database
const coll = stitchClient
.getServiceClient(RemoteMongoClient.factory, 'mongodb-atlas')
.db('Demo')
.collection('Users');
MongoDB Services Functions
Stitch Concepts
#MDBlocal
// Authenticate, then add and retrieve documents.
stitchClient.auth.loginWithCredential(
// You can use loginWithCredential() to access any auth provider
// Providers include:
// - Anonymous
// - Email/Password
// - Facebook
// - Google
// - API Keys
// - Custom (signed JWT)
MongoDB Services Functions
Stitch Concepts
#MDBlocal
// Authenticate, then query the database
stitchClient.auth.loginWithCredential(new AnonymousCredential())
.then(() =>
coll.find().asArray()
).then(users =>
...
);
// Or execute almost any CRUD/Aggregate command
coll.find({})
.aggregate([…])
.count(…)
.deleteMany(…) / .deleteOne(…)
.insertMany(…) / .insertOne(…)
.updateMany(…) / .updateOne(…)
MongoDB Services Functions
Stitch Concepts
#MDBlocal
const twilio = stitchClient.getServiceClient(
TwilioServiceClient.factory, "myTwilioService");
twilio.sendMessage(toPhone, fromPhone, 'A message from Stitch!')
.then(() => console.log('success!'));
sesService.send(fromEmail, toEmail, message)
.then(() => … );
s3Service.put(bucket, key, acl, contentType)
.then(() => … );
MongoDB Services Functions
Stitch Concepts
Stitch Functions & Triggers
Stitch Functions
Stitch is a collection of servers that
process application requests
Requests:
• Single actions for Database or Services
• Or executing a Stitch Function
• Integrated with Stitch’s Rules
Functions:
• Scalable, hosted JavaScript (ES6) Functions
• Integrated with application context
• User, Request, Services, Values, etc.
Stitch Functions
addtoCart calcStats
… sendMail
Application
(Stitch SDK)
MongoDB
#MDBlocal
client.callFunction('sendWeather', 'Seattle');
MongoDB Services Functions
Stitch Concepts
#MDBlocal
client.callFunction('sendWeather', 'Seattle');
MongoDB Services Functions
Stitch Concepts
exports = function(city) {
let mongodb = context.services.get("mongodb-atlas");
let UserColl = mongodb.db("StitchDemo").collection("Users");
let twilio = context.services.get("twilio");
let weather = context.services.get("weatherAPI");
let users = UserColl.find({"city": city});
let forecast = weather.get({context.values.get("weatherURL") + city});
let statuses = [];
return Promise.all(users, forecast).then(data => {
for(var i in data.users){
statuses.push(twilio.send(context.values.get("twilio")), data.users[i].Phone,
data.forecast);
}
return Promise.all(statuses);
});
}
Stitch Triggers
Stitch Triggers
• Register a Trigger in your app
• Stitch creates, maintains Change Stream
• Monitors for changes
• Runs Functions on matching changes
Benefits of Stitch Triggers
• React to database events in real-time
• Respond with hosted JavaScript functions
• Separate resources from databse
• Fully managed environment
• Access to broad application context
Stitch Functions
MongoDB
addtoCart calcStats … sendMail
order
Stitch Triggers
Trigger Types
• Database Triggers
• Authentication Triggers
• Scheduled Triggers
Stitch Functions
MongoDB
addtoCart calcStats … sendMail
order
Mobile Sync & CLI/UI
Stitch Mobile Sync (Beta)
Stitch Mobile Sync (Beta)
• Define a list of documents to Sync
• Define client-side change/conflict handling
• Use the Stitch SDK to seamless operate locally and
remotely – even when your application is offline
Benefits of Mobile Sync
• Simplify end-to-end application creation
• Enable applications to operate offline
• React to backend changes in realtime
• Simple conflict resolution
• Fully-managed, serverless solution
Stitch Mobile Sync
MongoDB order
• Import/Export your application configuration
• Develop with Stitch locally
• Add to repositories for versioning and
collaboration
• Easily move code between environments
• Use structure from existing apps to create
something new
Develop with Stitch – Stitch CLI
yourStitchApp/
├── stitch.json
├── auth_providers/
│ └── <provider name>.json
├── functions/
│ └── <function name>/
│ ├── config.json
│ └── source.js
├── services/
│ └── <service name>/
│ ├── config.json
│ ├── incoming_webhooks/
│ │ ├── config.json
│ │ └── source.js
│ └── rules/
│ └── <rule name>.json
| ...
Develop with Stitch – Console and Logs
Stitch Console
• Run functions in the Stitch UI
• Spoof specific users to test
permissions
Stitch Logs
• Information on all requests run
• Get info on: results. runtime,
errors, billing, etc.
• Easy to sort/filter/download
Develop with Stitch – Console and Logs
Stitch Console
• Run functions in the Stitch UI
• Spoof specific users to test
permissions
Stitch Logs
• Information on all requests run
• Get info on: results. runtime,
errors, billing, etc.
• Easy to sort/filter/download
Simple & Cheap Consumption Pricing
• Optimized for application requests
• Streamlined with Atlas
Compute
• $0.000025 per GB-s for Compute
• Runtime - Length of request in ms
• Memory - Max memory used in MB
• First 1,000,000 functions or 100,000GB-s free
Data Transfer
• $.5/GB Data Downloaded
• 25 GB Data free/month
• Transfer to Atlas is free
Pricing
• Get started with Stitch – stitch.mongodb.com
• Check out SDKs and examples –
• Code at github.com/mongodb/stitch-examples
• Docs at docs.mongodb.com/stitch
• Build the Dashboard or IoT apps in our Tutorials section
• Check out the code from today – codepen.io/drewdipalma
• Ask questions or let us know what you’re building through Intercom
What next?
Thank You!

More Related Content

Similar to Evolving your Data Access with MongoDB Stitch (20)

PPTX
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
MongoDB
 
PPTX
Building Your First App with MongoDB Stitch
MongoDB
 
PPTX
MongoDB World 2018: Evolving your Data Access with MongoDB Stitch
MongoDB
 
PPTX
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 
PPTX
[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch
MongoDB
 
PDF
Faites évoluer votre accès aux données avec MongoDB Stitch
MongoDB
 
PPTX
Eagle6 mongo dc revised
MongoDB
 
PPTX
Eagle6 Enterprise Situational Awareness
MongoDB
 
PPTX
SH 1 - SES 8 - Stitch_Overview_TLV.pptx
MongoDB
 
PDF
MongoDB World 2019: Securing Application Data from Day One
MongoDB
 
PPTX
MongoDB Stitch Introduction
MongoDB
 
PDF
fundamentalsofeventdrivenmicroservices11728489736099.pdf
Smarak Pani
 
PPTX
MongoDB Stich Overview
MongoDB
 
PPTX
A miało być tak... bez wycieków
Konrad Kokosa
 
PDF
Medium TechTalk — iOS
jimmyatmedium
 
PDF
Life on Clouds: a forensics overview
Reality Net System Solutions
 
PDF
User Expectations in Mobile App Security
Tao Xie
 
PDF
Implementing and Visualizing Clickstream data with MongoDB
MongoDB
 
PPSX
Sencha Touch basic concepts, pros and cons
Oleg Gomozov
 
KEY
How Signpost uses MongoDB for Tracking and Analytics
mattinsler
 
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
MongoDB
 
Building Your First App with MongoDB Stitch
MongoDB
 
MongoDB World 2018: Evolving your Data Access with MongoDB Stitch
MongoDB
 
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 
[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch
MongoDB
 
Faites évoluer votre accès aux données avec MongoDB Stitch
MongoDB
 
Eagle6 mongo dc revised
MongoDB
 
Eagle6 Enterprise Situational Awareness
MongoDB
 
SH 1 - SES 8 - Stitch_Overview_TLV.pptx
MongoDB
 
MongoDB World 2019: Securing Application Data from Day One
MongoDB
 
MongoDB Stitch Introduction
MongoDB
 
fundamentalsofeventdrivenmicroservices11728489736099.pdf
Smarak Pani
 
MongoDB Stich Overview
MongoDB
 
A miało być tak... bez wycieków
Konrad Kokosa
 
Medium TechTalk — iOS
jimmyatmedium
 
Life on Clouds: a forensics overview
Reality Net System Solutions
 
User Expectations in Mobile App Security
Tao Xie
 
Implementing and Visualizing Clickstream data with MongoDB
MongoDB
 
Sencha Touch basic concepts, pros and cons
Oleg Gomozov
 
How Signpost uses MongoDB for Tracking and Analytics
mattinsler
 

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
 
Ad

Recently uploaded (20)

PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PPTX
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
Letasoft Sound Booster 1.12.0.538 Crack Download+ Product Key [Latest]
HyperPc soft
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Letasoft Sound Booster 1.12.0.538 Crack Download+ Product Key [Latest]
HyperPc soft
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Ad

Evolving your Data Access with MongoDB Stitch

  • 2. Evolving Data Access with MongoDB Stitch Pavel Duchovny – Sr. Technical Services Engineer, MongoDB
  • 3. Rendering Data App ServerDatabase IoT DevicesPhone Browser Logic CRUD Email QueuesAccess Control Payments State Sign On Service Coordination Image Processing Applications are evolving State/Logic State Logic
  • 4. Rendering Data Database IoT DevicesPhone Browser State Logic Email Queues State Sign On Access Control Service Coordination Image Processin g Payments Applications are evolving CRUD
  • 5. How is development evolving? Application are living in more locations: • 48% of apps have backends deployed to a public cloud • 58% of apps are now developed for multiple platforms More is expected of development: • 64% of developers identified as full-stack (2017) Too much time is spent on maintainence •41% of time spent maintaining •39% on new projects Deploy and scale your application seamlessly Write straightforward, standard code Build simple, secure integrations
  • 6. Presentation UI Components UI Process Components Business Business Workflow Business Components Business Entities Application Facade Data Data Access Components Data Helper Utilities Server Agents Data Sources Services Users External Systems Service Interface CrossCutting Security OperationalManagement Communication Traditional Applications…. • Contain many, separate layers • Each layer is separate code, infrastructure • Connecting/Maintaining layers is lots of work Building an Application with Stitch Security & Auth Integration Business Logic Data Access Hosting
  • 7. Traditional Applications…. • Contain many, separate layers • Each layer is separate code, infrastructure • Connecting/Maintaining layers is lots of work Building an Application with Stitch Building applications with Stitch.... • No infrastructure to scale/patch/manage • Simplified service integrations • Easy to configure security • Hosted, serverless business logic Presentatio n UI Components UI Process Components Business Business Workflow Business Components Business Entities Application Facade Data Data Access Components Data Helper Utilities Server Agents Data Sources Services Users External Systems
  • 8. Stitch is comprised of 4 services – QueryAnywhere Simple, streamlined syntax for data access, robust access rules, hosting included Build full apps for iOS, Android, Web, and IoT Functions Integrate server-side logic + microservices + cloud services Power apps with Server-side logic, or enable Data as a Service with custom APIs. Triggers Real-time notifications let your application functions react in response to database changes App responds immediately to change Mobile Sync Automatically synchronizes data between documents held locally in MongoDB Mobile and your backend database (Beta)
  • 10. MongoDB Query Language + Native DriversIntegrated Rules Functions3rd Party Services Native SDKs (JavaScript, Android, iOS) Rest API Stitch QueryAnywhere
  • 12. { "userid":"101", "name": "Bernice Herrera", "employeeId": 53164957, "zip": 2082, "position": "IT Manager", "manager": "Ralph McBride", "hiringDate": ISODate("2017-05-02"), "employeeSource": "website ads", "salary": 205000, "gender": "female", "dob": ISODate("1972-10-02"), "citizenship": "Australia", "email": "[email protected]", "empStatus": "active" } Sensitive Information Example: Employee Data
  • 13. User db.collection.find() (plus user info) db.collection.find({"empStatus": "active"}) [{ userid: "101" name: …, salary: …, empStatus:"active" },{ userid: "404" name: …, salary: …, empStatus: "terminated", }] Results { "name": "ActiveOnly", "apply_when": {"%%true" : true}, "query": {"empStatus":"active"} } Filters contain an apply_when and a Query which is appended to a request [{ userid: "101" name: …, salary: …, empStatus:"active" }] Filters
  • 14. [{ userid: "101" name: … salary: … empStatus: "active"}, { userid: "202" name: … salary: … empStatus:"active" }] Roles are defined by Match statements, evaluated per document, and assign a set of Rules per document User {name: "OwnData", apply_when: {"userid":"%%user.id"}, fields: {…} } [{ userid: "101" name: … salary: … empStatus: "active"}, { userid: "202" name: … salary: … empStatus:"active" }] userid: "101" Roles : OwnData
  • 15. User Each Role has a set of matching Rules that define read and write access at the field-level [{ userid: "101" name: … salary: … empStatus: "active"}, { userid: "202" name: … salary: … empStatus:"active" }] [{ name: … salary: …}, { userid: "202" name: … salary: … empStatus:"active" }] Rules : OwnData "fields": { "name" :{ "read": true}, "salary":{"read": true} }, "additional_fields": { "read": false, "write": false } userid: "101"
  • 16. Roles are defined by Match statements, evaluated per document, and assign a set of Rules per document User {name: "Everyone", apply_when: {"%%true":true}, fields: {…} } [{ name: … salary: …}, { userid: "202" name: … salary: … empStatus:"active" }] [{ name: … salary: …}, { userid: "202" name: … salary: … empStatus:"active" }] userid: "101" Roles : Everyone
  • 17. User Each Role has a set of matching Rules that define read and write access at the field-level [{ name: … salary: …}, { userid: "202" name: … salary: … empStatus:"active" }] [{ name:… salary: … },{ name: … }] "fields": { "name" :{ "read": true}, }, "additional_fields": { "read": false, "write": false } userid: "101" Rules : Everyone
  • 18. OwnData Everyone { userid: "202" name: … salary: … empStatus: "active" } { userid: "101" name: … salary: … empStatus: "active" } { name: … salary: … } { name: … } Data Access
  • 19. { "filters": [{ "name": "ActiveOnly", "apply_when": {"%%true" : true}, "query": {"empStatus":"active"} }, … ], "roles": [{ name: "OwnData" apply_when: {"userid":"%%user.id"} "fields": { "name": {"read": true}, "salary": {"read": true}} }, "additional fields": { "read": false, "write": false }}, … ], "schema": {…} } Filters Roles Rules Schema Rules Structure
  • 20. schema: { bsonType: "object", required: ["userid", "email", "name"], properties: { userid: { bsonType: "objectid", description: "The ID of the Stitch user" }, email: { bsonType: "string", description: "must be a string and is required" }, name: { bsonType: "string", description: "must be a string and is required" } } JSON Schema
  • 21. schema: { bsonType: "object", required: ["userid", "email", "name"], properties: { userid: { bsonType: "objectid", description: "The ID of the Stitch user" }, email: { bsonType: "string", validate: {"%%true": { "%function": { "name": "isValid", "arguments": ["%%user", "%%this"]} }}, description: "must be a string and is not required" }, name: { bsonType: "bool", description: "True if the data is a secret" } [...] Schema Validation
  • 22. #MDBlocal const stitchClient = stitch.initializeDefaultAppClient('myApp'); // Connect to a MongoDB Atlas database const coll = stitchClient .getServiceClient(RemoteMongoClient.factory, 'mongodb-atlas') .db('Demo') .collection('Users'); MongoDB Services Functions Stitch Concepts
  • 23. #MDBlocal // Authenticate, then add and retrieve documents. stitchClient.auth.loginWithCredential( // You can use loginWithCredential() to access any auth provider // Providers include: // - Anonymous // - Email/Password // - Facebook // - Google // - API Keys // - Custom (signed JWT) MongoDB Services Functions Stitch Concepts
  • 24. #MDBlocal // Authenticate, then query the database stitchClient.auth.loginWithCredential(new AnonymousCredential()) .then(() => coll.find().asArray() ).then(users => ... ); // Or execute almost any CRUD/Aggregate command coll.find({}) .aggregate([…]) .count(…) .deleteMany(…) / .deleteOne(…) .insertMany(…) / .insertOne(…) .updateMany(…) / .updateOne(…) MongoDB Services Functions Stitch Concepts
  • 25. #MDBlocal const twilio = stitchClient.getServiceClient( TwilioServiceClient.factory, "myTwilioService"); twilio.sendMessage(toPhone, fromPhone, 'A message from Stitch!') .then(() => console.log('success!')); sesService.send(fromEmail, toEmail, message) .then(() => … ); s3Service.put(bucket, key, acl, contentType) .then(() => … ); MongoDB Services Functions Stitch Concepts
  • 26. Stitch Functions & Triggers
  • 27. Stitch Functions Stitch is a collection of servers that process application requests Requests: • Single actions for Database or Services • Or executing a Stitch Function • Integrated with Stitch’s Rules Functions: • Scalable, hosted JavaScript (ES6) Functions • Integrated with application context • User, Request, Services, Values, etc. Stitch Functions addtoCart calcStats … sendMail Application (Stitch SDK) MongoDB
  • 29. #MDBlocal client.callFunction('sendWeather', 'Seattle'); MongoDB Services Functions Stitch Concepts exports = function(city) { let mongodb = context.services.get("mongodb-atlas"); let UserColl = mongodb.db("StitchDemo").collection("Users"); let twilio = context.services.get("twilio"); let weather = context.services.get("weatherAPI"); let users = UserColl.find({"city": city}); let forecast = weather.get({context.values.get("weatherURL") + city}); let statuses = []; return Promise.all(users, forecast).then(data => { for(var i in data.users){ statuses.push(twilio.send(context.values.get("twilio")), data.users[i].Phone, data.forecast); } return Promise.all(statuses); }); }
  • 30. Stitch Triggers Stitch Triggers • Register a Trigger in your app • Stitch creates, maintains Change Stream • Monitors for changes • Runs Functions on matching changes Benefits of Stitch Triggers • React to database events in real-time • Respond with hosted JavaScript functions • Separate resources from databse • Fully managed environment • Access to broad application context Stitch Functions MongoDB addtoCart calcStats … sendMail order
  • 31. Stitch Triggers Trigger Types • Database Triggers • Authentication Triggers • Scheduled Triggers Stitch Functions MongoDB addtoCart calcStats … sendMail order
  • 32. Mobile Sync & CLI/UI
  • 33. Stitch Mobile Sync (Beta) Stitch Mobile Sync (Beta) • Define a list of documents to Sync • Define client-side change/conflict handling • Use the Stitch SDK to seamless operate locally and remotely – even when your application is offline Benefits of Mobile Sync • Simplify end-to-end application creation • Enable applications to operate offline • React to backend changes in realtime • Simple conflict resolution • Fully-managed, serverless solution Stitch Mobile Sync MongoDB order
  • 34. • Import/Export your application configuration • Develop with Stitch locally • Add to repositories for versioning and collaboration • Easily move code between environments • Use structure from existing apps to create something new Develop with Stitch – Stitch CLI yourStitchApp/ ├── stitch.json ├── auth_providers/ │ └── <provider name>.json ├── functions/ │ └── <function name>/ │ ├── config.json │ └── source.js ├── services/ │ └── <service name>/ │ ├── config.json │ ├── incoming_webhooks/ │ │ ├── config.json │ │ └── source.js │ └── rules/ │ └── <rule name>.json | ...
  • 35. Develop with Stitch – Console and Logs Stitch Console • Run functions in the Stitch UI • Spoof specific users to test permissions Stitch Logs • Information on all requests run • Get info on: results. runtime, errors, billing, etc. • Easy to sort/filter/download
  • 36. Develop with Stitch – Console and Logs Stitch Console • Run functions in the Stitch UI • Spoof specific users to test permissions Stitch Logs • Information on all requests run • Get info on: results. runtime, errors, billing, etc. • Easy to sort/filter/download
  • 37. Simple & Cheap Consumption Pricing • Optimized for application requests • Streamlined with Atlas Compute • $0.000025 per GB-s for Compute • Runtime - Length of request in ms • Memory - Max memory used in MB • First 1,000,000 functions or 100,000GB-s free Data Transfer • $.5/GB Data Downloaded • 25 GB Data free/month • Transfer to Atlas is free Pricing
  • 38. • Get started with Stitch – stitch.mongodb.com • Check out SDKs and examples – • Code at github.com/mongodb/stitch-examples • Docs at docs.mongodb.com/stitch • Build the Dashboard or IoT apps in our Tutorials section • Check out the code from today – codepen.io/drewdipalma • Ask questions or let us know what you’re building through Intercom What next?