Overview of MongoDB's BaaS offering: MongoDB Stitch
Tags: mongodbstitch, mongodb, nosql, baas
Published: 2017-06-28 22:48:04

---
title: "Overview of MongoDB's BaaS offering: MongoDB Stitch"
published: true
description: An overview of MongoDB's backend as a service offering, MongoDB Stitch. A look at the benefits of using MongoDB Stitch and some of its features.
tags: MongoDB Stitch, MongoDB, NoSQL, Baas
cover_image: https://thepracticaldev.s3.amazonaws.com/i/g4wuhk7nbm1ob8z73obj.png
canonical_url: https://www.kenwalger.com/blog/nosql/mongodb/mongodbs-baas-offering-stitch/
---

One of the challenges many developers have is keeping up with backend processes. Things like data security, service integrations, and code for data manipulations can take up a lot of time and resources. As a result, many have made a move to utilize a Backend as a Service (BaaS). If you have an application backed by <a href="http://www.mongodb.com">MongoDB</a>Â there is a new Baas option available, MongoDB Stitch.

MongoDB allows you to <a href="https://www.mongodb.com/cloud/stitch">get started</a> at no cost with Stitch, which is always great. At the moment it is backed by MongoDB's Database as a Service (DBaaS) offering, <a href="https://www.mongodb.com/cloud/atlas/">Atlas</a>. In <a href="https://www.kenwalger.com/blog/nosql/mongodb/mongodb-atlas/">another post</a>, I discussed Atlas and am excited that these two services are connected.
<h3>BaaS Overview</h3>
A Backend as a Service approach to development allows mobile and web developers to connect their applications to backend cloud storage and utilize inherentÂ processing capabilities. Further, it provides many common features that users demand from sites and applications. Some of these features are security, user management, push notifications, and social networking integrations.
<h3>MongoDB Stitch Benefits</h3>
Stitch provides many capabilitiesÂ for developers to leverage the features inherentÂ in MongoDB along with BaaS concepts. It provides direct access to the database, whether it is already existing or new data, Stitch allows developers to focus on building their application. The backend logic is taken care of and provided.Â This leads to a faster development cycle.

Stitch takes MongoDB's data <a href="https://docs.mongodb.com/manual/security/">security features</a> even further. It provides functionality such as end user authentication and access control on a per-field basis. For example, if the marketing department doesn't need access to a customer's financial information, those fieldsÂ can be excluded from their access rights. This allows developers and application stakeholders to have confidence that information and services are only available to the proper users.

MongoDB has built Stitch in an open fashion. It provides a single API allowing access to both the MongoDB database as well as other public cloud services. This allows for microservice integration and prevents being committed to a single vendor.

Another terrific benefit is the integration with Atlas. This allows for easy scaling of capacity and performance as an application grows. This is yet another set of duties that don't need to be managed ourselves. We can allow the details of the backend application and infrastructure to be handled by a team of Dev-Ops folks at MongoDB and can then concentrate on the application itself.
<h3>MongoDB Stitch Components</h3>
There are three main components of Stitch, <a href="https://docs.mongodb.com/stitch/pipelines/">pipelines</a>, services, and <a href="https://docs.mongodb.com/stitch/rules/">rules</a>. Services come in two different varieties, <a href="https://docs.mongodb.com/stitch/services/mongodb/">MongoDB services</a>, and <a href="https://docs.mongodb.com/stitch/services/">partner services</a> for integration with services like Amazon S3 or TwilioÂ for messaging. Let's take a quick look at what these different components do and how they fit into an application.
<h6>Services</h6>
Services in Stitch allow for application integration and execution of common actions. There are integrations for a variety of third-party (partner) services for such tasks as user authentication through Facebook or Google, Slack, Twilio, and some components of AWS, to name a few. The <a href="https://docs.mongodb.com/stitch/services/http/">HTTP Service</a> allows for a MongoDB Stitch application to connect to REST API services. MongoDB has a dedicated service for connecting to Atlas and has some built in pipeline operations.
<h6>Pipelines</h6>
A Stitch pipeline allows for a sequence of actions to be performed in order by the Stitch services. This is a powerful feature. It allows a series of actions to be defined all through simple JSON syntax.

A pipeline is built in stages, each running in consecutive order. A stage runs and passes the information it generates onto the next stage. For example, you can do a MongoDB aggregation stage from your data and determine which user in the past week had the most likes on your new Snap-o-gram app. That stage could then pass that information to the Twilio Service which could send a text to their phone with this awesome accomplishment.

There are some Built-In Actions for filtering the pipeline input, defining in an explicit way what the output of a stage will be, expression evaluation against input documents, and a project feature, to name a few. Another nice feature MongoDB has provided is the concept of <a href="https://docs.mongodb.com/stitch/reference/namedpipelines/">named pipelines</a>. This allows for a designed pipeline to be reused within a Stitch app and referenced by name. A tremendous help for writing code that follows the DRY (don't repeat yourself) principle.
<h6>Rules</h6>
The last major component of a MongoDB Stitch is Rules. Rules, as one might guess, allow for a control over the actions a service takes. Rules are designed and written in JSON format, as are pipelines.

One can define a rule for read, write, and validation operations, for example. These can be used at the document and on down to the field level. Want to prevent a service from reading specific financial data in a document? Write a rule for that. It is a powerful feature of MongoDB Stitch and provides an extra level of security for your data.
<h3>MongoDB Stitch Development</h3>
Right now there are three different options for developing a Stitch application. Using JavaScript for web applications and for mobile development there are options for Android and iOS. MongoDB has put together some great <a href="https://docs.mongodb.com/stitch/tutorials/">tutorials</a> and <a href="https://docs.mongodb.com/stitch/getting-started/first-stitch-app/">getting started</a> guides.
<h3>Wrap Up</h3>
The name Stitch comes out of the idea of stitching together the pieces of an application and not from the Disney character in <a href="https://www.amazon.com/gp/product/B00009XMNJ/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B00009XMNJ&amp;linkCode=as2&amp;tag=kenwalgersite-20&amp;linkId=d2d5a61e657b363b42c52c8968b778e8" target="_blank" rel="noopener">Lilo &amp; Stitch</a><img style="border: none !important; margin: 0px !important;" src="//ir-na.amazon-adsystem.com/e/ir?t=kenwalgersite-20&amp;l=am2&amp;o=1&amp;a=B00009XMNJ" alt="" width="1" height="1" border="0" />. Given the benefits and features MongoDB Stitch brings to the table, I think it is a very appropriate name. Much like <a href="https://www.amazon.com/gp/product/B015KM765Y/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B015KM765Y&amp;linkCode=as2&amp;tag=kenwalgersite-20&amp;linkId=79470d1ee6a76031c019d66162f4c4ba" target="_blank" rel="noopener">sewing</a><img style="border: none !important; margin: 0px !important;" src="//ir-na.amazon-adsystem.com/e/ir?t=kenwalgersite-20&amp;l=am2&amp;o=1&amp;a=B015KM765Y" alt="" width="1" height="1" border="0" />Â brings all of the pieces of a garment together, MongoDB Stitch does the same thing for your application.

I know that for myself I plan on utilizing this service on my next project.

As with any "pre-packaged" service, one gives up some flexibility and control over your application. However, for being able to retain direct access to your MongoDB database, and the <a href="https://docs.mongodb.com/manual/reference/glossary/#collection">collections</a> and <a href="https://www.kenwalger.com/blog/nosql/document-model/">documents</a> it contains, Stitch is a great option.Â Keep in mind that as of this post, Stitch is still in a beta version. As with any beta product, things may change with the final product.

There are several MongoDB specific terms in this post. I created a <a href="https://www.echoskillstore.com/MongoDB-Dictionary/45103">MongoDB Dictionary</a> skill for the <a href="https://www.amazon.com/gp/product/B01DFKC2SO/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B01DFKC2SO&amp;linkCode=as2&amp;tag=kenwalgersite-20&amp;linkId=f9e513223de2525a72b95cf9561db55b" rel="noopener noreferrer">Amazon Echo</a>Â line of products. Check it out and you can say "Alexa, ask MongoDB for the definition of authentication?" and get a helpful response.

<hr />

<em>Follow me on Twitter <a href="https://www.twitter.com/kenwalger">@kenwalger</a> to get the latest updates on my postings.</em>