#MDBlocal
16 JANUARY, 2018 | HILTON
#MDBlocal
Drew DiPalma
Product Manager – Stitch
#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
Functions 3rd Party Services
Native SDKs (JavaScript, Android, iOS)
Rest-like API
#MDBlocal
• A full backend with built-in scalability and high-availability
• Key management covered by Atlas
• Retain direct data access
• Combined with tools for building your application
• Service Integrations (including authentication)
• Hosted JavaScript functions
• Declarative access rules
• No lock-in
• Atlas available in AWS, Azure, and GCP
• Atlas in most regions, Stitch in AWS US East for Beta
Stitch + Atlas
#MDBlocal
How requests work…
1. Application request is made
1
#MDBlocal
How requests work…
1. Application request is made
2. Stitch parses and applies write rules
2
#MDBlocal
How requests work…
1. Application request is made
2. Stitch parses and applies write rules
3. Stitch orchestrates DB + Services
3
3
#MDBlocal
How requests work…
1. Application request is made
2. Stitch parses and applies write 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 write rules
3. Stitch orchestrates DB + Services
4. Stitch aggregates and applies rules
5. Client receives results 5
const stitchClient = new StitchClient('APP-ID');
const mongodbClient = stitchClient.service('mongodb', 'mongodb-atlas');
MongoDB Services Functions
Stitch Concepts
const stitchClient = new StitchClient('APP-ID');
const mongodbClient = stitchClient.service('mongodb', 'mongodb-atlas');
const db = mongoClient.db('guidebook');
const coll = db.collection('restaurants');
stitchClient.authenticate('providerType', {options})
MongoDB Services Functions
Stitch Concepts
const stitchClient = new StitchClient('APP-ID');
const mongodbClient = stitchClient.service('mongodb', 'mongodb-atlas');
const db = mongoClient.db('guidebook');
const coll = db.collection('restaurants');
stitchClient.authenticate('providerType', {options})
coll.find({'name' : text })
MongoDB Services Functions
Stitch Concepts
const stitchClient = new StitchClient('APP-ID');
const mongodbClient = stitchClient.service('mongodb', 'mongodb-atlas');
const db = mongoClient.db('guidebook');
const coll = db.collection('restaurants');
stitchClient.authenticate('providerType', {options})
coll.find({'name' : text })
.count(….)
.deleteMany(….)
.deleteOne(….)
.insertMany(….)
.insertOne(….)
.updateMany(….)
.updateOne(….)
Stitch Concepts
MongoDB Services Functions
const slackService = client.service('slack', 'slackService')
slackService.post('slackChannel', 'slack username', message)
const twilioService = client.service('twilio', 'twilioService')
twilioService.send('+120155555553', '+12018675309', message)
const s3Service = client.service('s3', 's3Service')
s3Service.signPolicy(bucket, key, acl, contentType)
MongoDB Services Pipelines
Stitch Concepts
stitchClient.executeFunction('sendWeather', 'Tel Aviv');
MongoDB Services Functions
Stitch Concepts
stitchClient.executeFunction('sendWeather', 'Tel Aviv');
MongoDB Services Functions
Stitch Concepts
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 status;
}
#MDBlocal
• Fine-grained data access controls
• Base access on document/field/value
• Authorize the user, not just the app
• Associate with user profile, MDB Data,
or external info
• Define with simple JSON or link to
functions
Declarative Access Controls
#MDBlocal
Atlas
Customer Account Data
{
"owner_id": … ,
"balance": … ,
"transactions": {…},
"user_profile": {….}
}Bank Teller
Analyst
Customer
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
Analyst
Customer
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": "CheckAuth",
"args": { "AuthType": "server",
"UserAuth": "%%user.type"}
}
]
}
{
"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": "CheckAuth",
"args": { "AuthType": "server",
"UserAuth": "%%user.type"}
}
]
}
Bank Teller
Analyst
Customer
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": "CheckAuth",
"args": { "AuthType": "server",
"UserAuth": "%%user.type"}
}
]
}
Bank Teller
Analyst
Customer
{Aggregated
Data}
Stitch
Function for Analysis
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 DB / Request
Processing
#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
#MDBlocal
Stitch Demo
#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
Everywhere
Expand Regional footprint
Available on-premise
Bring any MongoDB
Realtime
Change Streams driven
Event-based pipelines
Dev Tools
Code and Rule Versioning
Debugging and Monitoring
Service Extensibility
What’s Next?
#MDBlocal
• 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?

SH 1 - SES 8 - Stitch_Overview_TLV.pptx

  • 1.
  • 2.
  • 3.
    #MDBlocal When building, youneed to… 1. Safely and easily access data 2. Integrate with key services 3. Scalably serve requests
  • 4.
    #MDBlocal MongoDB Query Language+ Native DriversIntegrated Rules Functions 3rd Party Services Native SDKs (JavaScript, Android, iOS) Rest-like API
  • 5.
    #MDBlocal • A fullbackend with built-in scalability and high-availability • Key management covered by Atlas • Retain direct data access • Combined with tools for building your application • Service Integrations (including authentication) • Hosted JavaScript functions • Declarative access rules • No lock-in • Atlas available in AWS, Azure, and GCP • Atlas in most regions, Stitch in AWS US East for Beta Stitch + Atlas
  • 6.
    #MDBlocal How requests work… 1.Application request is made 1
  • 7.
    #MDBlocal How requests work… 1.Application request is made 2. Stitch parses and applies write rules 2
  • 8.
    #MDBlocal How requests work… 1.Application request is made 2. Stitch parses and applies write rules 3. Stitch orchestrates DB + Services 3 3
  • 9.
    #MDBlocal How requests work… 1.Application request is made 2. Stitch parses and applies write rules 3. Stitch orchestrates DB + Services 4. Stitch aggregates and applies rules 4
  • 10.
    #MDBlocal How requests work… 1.Application request is made 2. Stitch parses and applies write rules 3. Stitch orchestrates DB + Services 4. Stitch aggregates and applies rules 5. Client receives results 5
  • 11.
    const stitchClient =new StitchClient('APP-ID'); const mongodbClient = stitchClient.service('mongodb', 'mongodb-atlas'); MongoDB Services Functions Stitch Concepts
  • 12.
    const stitchClient =new StitchClient('APP-ID'); const mongodbClient = stitchClient.service('mongodb', 'mongodb-atlas'); const db = mongoClient.db('guidebook'); const coll = db.collection('restaurants'); stitchClient.authenticate('providerType', {options}) MongoDB Services Functions Stitch Concepts
  • 13.
    const stitchClient =new StitchClient('APP-ID'); const mongodbClient = stitchClient.service('mongodb', 'mongodb-atlas'); const db = mongoClient.db('guidebook'); const coll = db.collection('restaurants'); stitchClient.authenticate('providerType', {options}) coll.find({'name' : text }) MongoDB Services Functions Stitch Concepts
  • 14.
    const stitchClient =new StitchClient('APP-ID'); const mongodbClient = stitchClient.service('mongodb', 'mongodb-atlas'); const db = mongoClient.db('guidebook'); const coll = db.collection('restaurants'); stitchClient.authenticate('providerType', {options}) coll.find({'name' : text }) .count(….) .deleteMany(….) .deleteOne(….) .insertMany(….) .insertOne(….) .updateMany(….) .updateOne(….) Stitch Concepts MongoDB Services Functions
  • 15.
    const slackService =client.service('slack', 'slackService') slackService.post('slackChannel', 'slack username', message) const twilioService = client.service('twilio', 'twilioService') twilioService.send('+120155555553', '+12018675309', message) const s3Service = client.service('s3', 's3Service') s3Service.signPolicy(bucket, key, acl, contentType) MongoDB Services Pipelines Stitch Concepts
  • 16.
  • 17.
    stitchClient.executeFunction('sendWeather', 'Tel Aviv'); MongoDBServices Functions Stitch Concepts 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 status; }
  • 18.
    #MDBlocal • Fine-grained dataaccess controls • Base access on document/field/value • Authorize the user, not just the app • Associate with user profile, MDB Data, or external info • Define with simple JSON or link to functions Declarative Access Controls
  • 19.
    #MDBlocal Atlas Customer Account Data { "owner_id":… , "balance": … , "transactions": {…}, "user_profile": {….} }Bank Teller Analyst Customer 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”
  • 20.
    #MDBlocal Bank Teller Analyst Customer Atlas Customer AccountData { "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": "CheckAuth", "args": { "AuthType": "server", "UserAuth": "%%user.type"} } ] } { "user_id": … , "balance": … , "transactions": {…}, "user_profile": {….} }
  • 21.
    #MDBlocal Stitch user_profile (Read Rule) {”owner_id": ”%%user.id"} balance/transactions (ReadRules) { ”%or": [ {”owner_id": ”%%user.id"}, {"%%true": { "%function": { "name": "CheckAuth", "args": { "AuthType": "server", "UserAuth": "%%user.type"} } ] } Bank Teller Analyst Customer Atlas Customer Account Data { "owner_id": … , "balance": … , "transactions": {…}, "user_profile": {….} } { "user_id": … , "balance": … , "transactions": {…} }
  • 22.
    #MDBlocal Stitch user_profile (Read Rule) {”owner_id": ”%%user.id"} balance/transactions (ReadRules) { ”%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": "CheckAuth", "args": { "AuthType": "server", "UserAuth": "%%user.type"} } ] } Bank Teller Analyst Customer {Aggregated Data} Stitch Function for Analysis Atlas Customer Account Data { "owner_id": … , "balance": … , "transactions": {…}, "user_profile": {….} }
  • 23.
  • 24.
    #MDBlocal Amazon S3 MongoDB Atlas twilioAmazon 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 DB / Request Processing
  • 25.
    #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
  • 26.
  • 27.
    #MDBlocal • $1 perGB of data transferred from Stitch to client/service • 25 GB Free per month • Data transfer to Atlas is free Pricing
  • 28.
    #MDBlocal xx Everywhere Expand Regional footprint Availableon-premise Bring any MongoDB Realtime Change Streams driven Event-based pipelines Dev Tools Code and Rule Versioning Debugging and Monitoring Service Extensibility What’s Next?
  • 29.
    #MDBlocal • Try outStitch – 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?