Speaker:Drew DiPalma
Learn more about MongoDB Stitch, our new Backend as a Service (BaaS) that makes it easy for developers to create and launch applications across mobile and web platforms. Stitch provides a REST API on top of MongoDB with read, write, and validation rules built-in and full integration with the services you love. This talk will cover the what, why, and how of MongoDB Stitch. We'll discuss everything from features to the architecture. You'll walk away knowing how Stitch can kickstart your new project or take your existing application to the next level.
MongoDB .local Paris 2020: Devenez explorateur de données avec MongoDB Charts
MongoDB Stich Overview
1. O C T O B E R 1 2 , 2 0 1 7 | B E S P O K E | S A N F R A N C I S C O
# M D B l o c a l
MongoDB Stitch Overview
2. # M D B l o c a l
Apps today need…
1. A good idea
2. Ways to easily work with data
3. Integrations with key services
4. Ability to scalably serve requests
3. # M D B l o c a l
MongoDB Query Language + Native DriversIntegrated Rules
Pipelines 3rd Party Services
Native SDKs (JavaScript, Android, iOS)
Rest-like API
4. # M D B l o c a l
• No need to sacrifice scalability, performance, or high-availability
• Key management covered by Atlas
• Retain traditional access methods
• Use drivers, shell, Compass, etc.
• Direct data access for data movement, analysis, or additional workflows
• No lock-in
• Atlas available across AWS, Azure, and GCP
• Stitch in AWS US East for Beta – Expansion upcoming
Benefits of Stitch + Atlas
5. # M D B l o c a l
Integrated services and
Pipelines for complex,
multi-stage workflows
Native SDKs for Android,
JS, and iOS clients
Direct Database Access
6. # M D B l o c a l
How requests work…
1. Application request is made
1
7. # M D B l o c a l
How requests work…
1. Application request is made
2. Stitch parses and applies write rules
8. # M D B l o c a l
How requests work…
1. Application request is made
2. Stitch parses and applies write rules
3. Stitch orchestrates DB + Services
9. # M D B l o c a l
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
10. # M D B l o c a l
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
11. # M D B l o c a l
MongoDB Stich Can…
Be a complete backend for your new application
Add a feature to an existing application
Help integrate a new service/API
Find new ways to expose existing data
29. # M D B l o c a l
Declarative Data Access Controls
• Fine-grained data access controls
• Base access on document, field, or value
• Authorize the user, not just the app
• Associate with user profile or any other info
• Defined with JSON rules, not code
30. # M D B l o c a l
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”
31. # M D B l o c a l
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": { "%pipeline":
{ "name": "CheckAuth",
"args": { "AuthType": "server",
"UserAuth": "%%user.type"}
}
]
}
{
"user_id": … ,
"balance": … ,
"transactions": {…},
"user_profile": {….}
}
32. # M D B l o c a l
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"}
}
]
}
Bank Teller
Analyst
Customer
Atlas
Customer Account Data
{
"owner_id": … ,
"balance": … ,
"transactions": {…},
"user_profile": {….}
}
{
"user_id": … ,
"balance": … ,
"transactions": {…}
}
33. # M D B l o c a l
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": { "%pipeline":
{ "name": "CheckAuth",
"args": { "AuthType": "server",
"UserAuth": "%%user.type"}
}
]
}
Bank Teller
Analyst
Customer
{Aggregated
Data}
Stitch
Pipeline for Analysis
{“$$pipeline.currentRole”:
“Analyst”}
Atlas
Customer Account Data
{
"owner_id": … ,
"balance": … ,
"transactions": {…},
"user_profile": {….}
}
35. What’s Next?
xx
Everywhere Realtime
Expand Regional footprint
Available on-premise
Bring any MongoDB
Change Streams driven
Event-based pipelines
More Tools
Code and Rule Versioning
Debugging and Monitoring
Service Extensibility
36. • $1 per GB of data transferred from Stitch to client/service
• Data transfer to Atlas is free
• 25 GB Free per month
Pricing
37. What now?
• Get started at our Tutorial later today!
• Implementing Your Full Stack App with MongoDB Stitch
• 1:45 – 3:15 in Breakout Room D
• Check out Stitch – stitch.mongodb.com
• Check out SDKs and examples
• Code at github.com/MongodbStitch
• Docs at docs.mongodb.com/stitch
• Build the Platespace app in our Tutorials section
• Ask Questions or let us know what you’re building through Intercom
Getting start with an app like I just showed is easy, we’re going to skip ahead of installing the js sdk, and you just start by creating a new Stitch client instance and pointing it to the Atlas instance that you linked to Stitch
After that you can point it to any database and collection within your instance
From there you can use simple and familiar syntax to access your data.
You can pretty much complete whatever CRUD options you like within the code
The same way that you define and work with MongoDB can also be extended to other patner services. It’s quite simple to link a service to Stitch in the UI, and then reference it and kick-off actions in your application code.
Getting start with an app like I just showed is easy, we’re going to skip ahead of installing the js sdk, and you just start by creating a new Stitch client instance and pointing it to the Atlas instance that you linked to Stitch
After that you can point it to any database and collection within your instance
From there you can use simple and familiar syntax to access your data.
You can pretty much complete whatever CRUD options you like within the code
The same way that you define and work with MongoDB can also be extended to other patner services. It’s quite simple to link a service to Stitch in the UI, and then reference it and kick-off actions in your application code.
Getting start with an app like I just showed is easy, we’re going to skip ahead of installing the js sdk, and you just start by creating a new Stitch client instance and pointing it to the Atlas instance that you linked to Stitch
After that you can point it to any database and collection within your instance
From there you can use simple and familiar syntax to access your data.
You can pretty much complete whatever CRUD options you like within the code
The same way that you define and work with MongoDB can also be extended to other patner services. It’s quite simple to link a service to Stitch in the UI, and then reference it and kick-off actions in your application code.
Getting start with an app like I just showed is easy, we’re going to skip ahead of installing the js sdk, and you just start by creating a new Stitch client instance and pointing it to the Atlas instance that you linked to Stitch
After that you can point it to any database and collection within your instance
From there you can use simple and familiar syntax to access your data.
You can pretty much complete whatever CRUD options you like within the code
The same way that you define and work with MongoDB can also be extended to other patner services. It’s quite simple to link a service to Stitch in the UI, and then reference it and kick-off actions in your application code.
See with Stitch, all you need to do is provide the identifying information for your service, such as a key. Stitch stores and encrypts these keys so there is no need to have a separate management service for your application.
Once the link is made you can reference these services and use pre-built actions to reference them from your code. For instance you can:
Create a slack service and post a message to slack
Create a twilio service and send a text message with twilio
Or even do something more complex, like creating an S3 service and using it to upload data to S3
You can even use our HTTP service to integrate your own favorite service or API
Now, the great thing is that these actions don’t live in isolation, they can interact with each other to produce complex interactions, and this is where pipelines come in.
A pipleline is a multi-stage operation built out of partner service and database actions. So for an example, let’s say that you had two services – MongoDB and Twilio.
You could create a pipeline that uses both of these services. Now, you can actually create pipelines in the UI and then reference them in code later, but right now I’m going to show you how you can simply build a pipeline directly in your application.
So, Pipelines are built up in simple stages. Let’s say in the first stage you want to you want to find all the users within your database that are in Chicago – this can easily be accomplished with a simple find statement.
Now, with the second stae you want to send all of those users a message, let’s say telling them that it’s going to rain. But how do you transfer data from on stage in the pipeline to another? Well, Stages lave a let clause that allows you to define values for a stage, but what you actually need is a way to bring in data from the previous stage, and we can do this with expansions.
A pipleline is a multi-stage operation built out of partner service and database actions. So for an example, let’s say that you had two services – MongoDB and Twilio.
You could create a pipeline that uses both of these services. Now, you can actually create pipelines in the UI and then reference them in code later, but right now I’m going to show you how you can simply build a pipeline directly in your application.
So, Pipelines are built up in simple stages. Let’s say in the first stage you want to you want to find all the users within your database that are in Chicago – this can easily be accomplished with a simple find statement.
Now, with the second stae you want to send all of those users a message, let’s say telling them that it’s going to rain. But how do you transfer data from on stage in the pipeline to another? Well, Stages lave a let clause that allows you to define values for a stage, but what you actually need is a way to bring in data from the previous stage, and we can do this with expansions.
A pipleline is a multi-stage operation built out of partner service and database actions. So for an example, let’s say that you had two services – MongoDB and Twilio.
You could create a pipeline that uses both of these services. Now, you can actually create pipelines in the UI and then reference them in code later, but right now I’m going to show you how you can simply build a pipeline directly in your application.
So, Pipelines are built up in simple stages. Let’s say in the first stage you want to you want to find all the users within your database that are in Chicago – this can easily be accomplished with a simple find statement.
Now, with the second stae you want to send all of those users a message, let’s say telling them that it’s going to rain. But how do you transfer data from on stage in the pipeline to another? Well, Stages lave a let clause that allows you to define values for a stage, but what you actually need is a way to bring in data from the previous stage, and we can do this with expansions.
A pipleline is a multi-stage operation built out of partner service and database actions. So for an example, let’s say that you had two services – MongoDB and Twilio.
You could create a pipeline that uses both of these services. Now, you can actually create pipelines in the UI and then reference them in code later, but right now I’m going to show you how you can simply build a pipeline directly in your application.
So, Pipelines are built up in simple stages. Let’s say in the first stage you want to you want to find all the users within your database that are in Chicago – this can easily be accomplished with a simple find statement.
Now, with the second stae you want to send all of those users a message, let’s say telling them that it’s going to rain. But how do you transfer data from on stage in the pipeline to another? Well, Stages lave a let clause that allows you to define values for a stage, but what you actually need is a way to bring in data from the previous stage, and we can do this with expansions.
A pipleline is a multi-stage operation built out of partner service and database actions. So for an example, let’s say that you had two services – MongoDB and Twilio.
You could create a pipeline that uses both of these services. Now, you can actually create pipelines in the UI and then reference them in code later, but right now I’m going to show you how you can simply build a pipeline directly in your application.
So, Pipelines are built up in simple stages. Let’s say in the first stage you want to you want to find all the users within your database that are in Chicago – this can easily be accomplished with a simple find statement.
Now, with the second stae you want to send all of those users a message, let’s say telling them that it’s going to rain. But how do you transfer data from on stage in the pipeline to another? Well, Stages lave a let clause that allows you to define values for a stage, but what you actually need is a way to bring in data from the previous stage, and we can do this with expansions.
So, here are two simple expansions, %%vars, which allows you use a variable defined in the let clause of the stage and %%item, which allows you to leverage data from the output of the previous stage.
Together these expansions allow you to easily find a subset of your users and send them a targeted message.
But expansions aren’t just limited to this, in fact they open up a whole slew of outside data that can be incorporated into your pipelines.
Keep a single source for business logic that can link to client and server
In many cases, business logic is duplicated between the client and server, as well as communication overhead between frontend and backend teams, making projects more difficult and delaying the time-to-market
There are really 4 types of expansions that we’ve included in this launch, and they can be used in everything from rules to pipelines. We’ll start with…
Global – Global values that span across all pipelines and rules
User – information aobut the User including authentication and metadata
MongoDB – Access the the current and previous states of fields and documents
Stage-specific – Stage specific variables, Reference data in prior stages, and even kick-off nested pipelines within the current rules or pipelines
And with all of this you can really see the value of pipelines and services really expand. To Re-iterate, pipelines:
Can contain service or database actions
Can simply string together stages and pass information between them
Can easily bring in outside information or call nested pipelines
You can really see that with this framework you can begin to push a lot of your logic and computation off of your devices and into Stitch. In the long run this is going to help you:
streamline your functionality over lots of different platforms
Adapt and upgrad functionality or integrate new services all without changing the application code or adding new infrastructure (or, on the other hand, accomplish at the client level even more quickly without looking at )
And as a reminder, you don’t need to build your whole app on stitch, you can bring an existing database or application and begin to add to it right off the bat.
And, while we’ve been talking about pipelines in your application, they can be easily defined at the UI as well as within the code
Now, with all of this power and flexibility, you want to make sure that you are being really precise about access to your services and underlying data. This is where rules really come into play…
There are really 4 types of expansions that we’ve included in this launch, and they can be used in everything from rules to pipelines. We’ll start with…
Global – Global values that span across all pipelines and rules
User – information aobut the User including authentication and metadata
MongoDB – Access the the current and previous states of fields and documents
Stage-specific – Stage specific variables, Reference data in prior stages, and even kick-off nested pipelines within the current rules or pipelines
And with all of this you can really see the value of pipelines and services really expand. To Re-iterate, pipelines:
Can contain service or database actions
Can simply string together stages and pass information between them
Can easily bring in outside information or call nested pipelines
You can really see that with this framework you can begin to push a lot of your logic and computation off of your devices and into Stitch. In the long run this is going to help you:
streamline your functionality over lots of different platforms
Adapt and upgrad functionality or integrate new services all without changing the application code or adding new infrastructure (or, on the other hand, accomplish at the client level even more quickly without looking at )
And as a reminder, you don’t need to build your whole app on stitch, you can bring an existing database or application and begin to add to it right off the bat.
And, while we’ve been talking about pipelines in your application, they can be easily defined at the UI as well as within the code
Now, with all of this power and flexibility, you want to make sure that you are being really precise about access to your services and underlying data. This is where rules really come into play…
There are really 4 types of expansions that we’ve included in this launch, and they can be used in everything from rules to pipelines. We’ll start with…
Global – Global values that span across all pipelines and rules
User – information aobut the User including authentication and metadata
MongoDB – Access the the current and previous states of fields and documents
Stage-specific – Stage specific variables, Reference data in prior stages, and even kick-off nested pipelines within the current rules or pipelines
And with all of this you can really see the value of pipelines and services really expand. To Re-iterate, pipelines:
Can contain service or database actions
Can simply string together stages and pass information between them
Can easily bring in outside information or call nested pipelines
You can really see that with this framework you can begin to push a lot of your logic and computation off of your devices and into Stitch. In the long run this is going to help you:
streamline your functionality over lots of different platforms
Adapt and upgrad functionality or integrate new services all without changing the application code or adding new infrastructure (or, on the other hand, accomplish at the client level even more quickly without looking at )
And as a reminder, you don’t need to build your whole app on stitch, you can bring an existing database or application and begin to add to it right off the bat.
And, while we’ve been talking about pipelines in your application, they can be easily defined at the UI as well as within the code
Now, with all of this power and flexibility, you want to make sure that you are being really precise about access to your services and underlying data. This is where rules really come into play…
There are really 4 types of expansions that we’ve included in this launch, and they can be used in everything from rules to pipelines. We’ll start with…
Global – Global values that span across all pipelines and rules
User – information aobut the User including authentication and metadata
MongoDB – Access the the current and previous states of fields and documents
Stage-specific – Stage specific variables, Reference data in prior stages, and even kick-off nested pipelines within the current rules or pipelines
And with all of this you can really see the value of pipelines and services really expand. To Re-iterate, pipelines:
Can contain service or database actions
Can simply string together stages and pass information between them
Can easily bring in outside information or call nested pipelines
You can really see that with this framework you can begin to push a lot of your logic and computation off of your devices and into Stitch. In the long run this is going to help you:
streamline your functionality over lots of different platforms
Adapt and upgrad functionality or integrate new services all without changing the application code or adding new infrastructure (or, on the other hand, accomplish at the client level even more quickly without looking at )
And as a reminder, you don’t need to build your whole app on stitch, you can bring an existing database or application and begin to add to it right off the bat.
And, while we’ve been talking about pipelines in your application, they can be easily defined at the UI as well as within the code
Now, with all of this power and flexibility, you want to make sure that you are being really precise about access to your services and underlying data. This is where rules really come into play…
In MongoDB Stitch we have the ability to create precise rules that cover all the major surfaces of your application – MongoDB, services, and pipelines.
For MongoDB, you can create read, write, and validation rules
And for other services you can create rules that precisely define when the service can be run, allowing you to limit service actions, paramaters to the services and the types or roles of users executing those services
Rules are defined with the same simple JSON that you use for pipelines.
So, for example you can create a simple read/write rule that check is the user id of the authenticated user is equivalent to the user that is defined as the owner of the document. Meaning that a user can only read or write documents that they own.
You can also create more complex rules that contain conditionals and expressions, even including pipelines. For example, if this were defined as a write rule it would allow users to edit documents that they owned OR create net new documents.
To make this a bit more concrete, let’s talk about how the rules work in action.
-------
Differentiate between MongoDB and Service Rules
Rules are declarative, easy to write and powerful
For MongoDB, Read, Write, and Validation rules at the document or field level
In MongoDB Stitch we have the ability to create precise rules that cover all the major surfaces of your application – MongoDB, services, and pipelines.
For MongoDB, you can create read, write, and validation rules
And for other services you can create rules that precisely define when the service can be run, allowing you to limit service actions, paramaters to the services and the types or roles of users executing those services
Rules are defined with the same simple JSON that you use for pipelines.
So, for example you can create a simple read/write rule that check is the user id of the authenticated user is equivalent to the user that is defined as the owner of the document. Meaning that a user can only read or write documents that they own.
You can also create more complex rules that contain conditionals and expressions, even including pipelines. For example, if this were defined as a write rule it would allow users to edit documents that they owned OR create net new documents.
To make this a bit more concrete, let’s talk about how the rules work in action.
-------
Differentiate between MongoDB and Service Rules
Rules are declarative, easy to write and powerful
For MongoDB, Read, Write, and Validation rules at the document or field level
Now, as you all know, Stitch has just been released in beta today. We think you can use it to build some pretty amazing things right off the bat, but I also want to give you the first sneak peak at what our focus is going to be for the foreseeable future.
First, we wanted to make Stitch available
For MongoDB users everywhere
This means expanding Stitch hosting to other cloud regions and providers
But it also extends to self-hosted and on-prem instances. We want Stitch to help you build on your data no matter where it resides.
Next is enabling realtime for Stitch
For everyone at the keynote, I’m sure you heard about the change notifiation work that is coming
We’re working super closely with that tealm to build realtime data and even pipelines for Stitch.
So, whilte others have hacked together realtime on top of MongoDB, we’re going to do this in a way that is really optimized for the database
Finally, we are laser focused on making sure that Stitch has all the capabilities to make developers successful
This is going to include everything from from code deployment and versions
Continually improving our debugging infrastructure
And finally continuing to advance our
The purpose of the pricing is to be simple and transparent.
Customers should be able to pay in the same ways as for Atlas.
Firebase has a complex planning scheme with 3 different plans. For each plan, there are limits, costs across 20 different dimensions. E.g. you pay for storage, uploads, download, invocations, authentication requests,…
Meteor have 4 prepaid plans + pay as you go (paying for a computing instance). No free tier. Support is extra
So, now that we’ve gotten a chance to talk a bit about Stitch…what next?
Well, if you’ve got time this afternoon one of our developer advocates and I will go even deeper with Stitch and show you how to build the app that I demo’d a bit earlier
But regardless, try out Stitch ASAP, it’s 100% free during world and then after that the first 25 GB of data downloaded is free, and each GB after that is only $1!
And, even though I’m not going to be able to take any questions during this sessions, please take a look at all the code and docs that we’ve released and come by the Stitch booth. I’ll be there alongside a lot of the engineers who brought Stitch to life.
So thanks again for taking time to learn a bit more about Stitch, now go and create something cool!