Please note: This article discusses Stitch. Stitch is now MongoDB Realm. All the same features and functionality, now with a new name. Learn more here. We will be updating this article in due course.
The Stitch SDK is the best way to access MongoDB Stitch from your frontend application code - getting to your data and accessing your Stitch Services and Functions becomes child's' play.
However, those already using MongoDB may have existing backend code and
tools that work with MongoDB. MongoDB Stitch now supports the MongoDB
wire protocol -
meaning that you can continue to work with your favorite tools
(including the mongo
shell) and drivers while benefiting from
Stitch's quick and simple data access control and hosted JavaScript
functions.
After enabling connection string access, connecting to your Stitch app
from the mongo
shell is business as usual - just use the connection
string you're shown in the Stitch UI:
1 mongo "mongodb://andrewjamXXXXX%40gmail.com:gXXXX@stitch.mongodb.com:27020\
/?authMechanism=PLAIN&authSource=%24external&ssl=true&\
appName=imported_trackme-xxxxz:mongodb-atlas:local-userpass" --norc
Once connected, adding a document through Stitch should feel very familiar:
1 db.comments.insert({ 2 owner_id: "5bacd4e7698a67f72dfdb44c", 3 author: "Andrew Morgan", 4 comment: "Stitch wire protocol support rocks!" 5 })

However, Stitch is about more than accessing MongoDB data. I've created
a (stupidly) simple Stitch (morning
) Function to show how you can
test your Stitch app:
1 exports = function(name){ 2 return {message: "Good Morning " + name + " from " 3 + context.user.data.email}; 4 };
From the mongo
shell, I can now test that function:
1 db.runCommand({ callFunction: "morning", arguments: ["Billy"] }) 2 { 3 "ok" : 1, 4 "response" : { 5 "message" : "Good Morning Billy from greetings@clusterdb.com" 6 } 7 }
Creating your first Stitch app? Start with one of the Stitch tutorials.
Want to learn more about MongoDB Stitch? Read the white paper.