Navigation

MongoDB Atlas Overview

With its integration with MongoDB Atlas, MongoDB Stitch allows you to take advantage of MongoDB features seamlessly. When you create a new Stitch application, you select an existing Atlas cluster to use with that application.

Note

For more information on Atlas, visit MongoDB Atlas, or visit the Atlas documentation.

Getting Started

You specify the Atlas cluster you want to use when initially setting up a new Stitch application, as shown in the following image:

../../_images/new_stitch_app.png

To walk through the process of setting up a new Stitch application, see the Getting Started guide: Create a Stitch App.

Accessing Atlas Data via MongoDB Stitch Apps

Before you can access Atlas data from Stitch apps, you must define a Stitch collection that maps to each Atlas collection the app will access. To learn more, see the Getting Started guide: Add MongoDB to Your Stitch App.

There are 2 ways that client applications can access the data used by your Stitch application. They can:

  • Use MongoDB Actions to make direct calls to Stitch collections.

    See Building Blog App for an example that uses the collection.find() action.

  • Execute a Stitch function.

    In addition to making calls to Atlas, Stitch functions can provide back-end logic, thus moving more of the data access logic to the back-end. For more information on Functions, see Functions.

In both cases, the Stitch Rules on the collection are applied during the call to Atlas.

Additional Considerations

Even if your Atlas cluster is exclusively used by Stitch applications, you may need to connect directly to your database instances, either via the mongo shell or another tool, like MongoDB Compass. Because the cluster is a standard MongoDB cluster, there are no special considerations when connecting.

However, if you are modifying the data outside of your Stitch application, you should be aware of a special reserved field that Stitch temporarily adds to documents. The _id_stitch_transaction field is used by Stitch when updating documents, and is removed when any given document is successfully updated. It is not normally available to Stitch apps.

If you are modifying documents outside of Stitch, you should $unset this field prior to making changes. For example, if you are using the mongo shell to update documents in the products collection, your command might resemble the following code:

db.products.update(
   { sku: "unknown" },
   { $unset: { _id_stitch_transaction: "" } }
)