- Stitch >
- MongoDB Atlas >
- Work With MongoDB
Connect Over the Wire Protocol¶
On this page
Overview¶
MongoDB Stitch natively implements a subset of the MongoDB wire protocol, which allows you to connect to a Stitch application through one of its linked MongoDB clusters using standard MongoDB drivers and tools. Clients use a specialized Stitch connection string to connect and send requests. Stitch supports most client features over the wire protocol, including role-based data access rules, functions, and service actions.
Prerequisites¶
You must enable wire protocol connections for one or more linked clusters in your application before you can connect over the wire protocol.
Compatible Clients¶
You can use the following tools and drivers to communicate with Stitch using a connection string:
- Version 4.0+ of the mongo shell.
- Any MongoDB driver that supports the
appName
connection string parameter. All official MongoDB drivers support this parameter in their current releases.
Note
Connections to Stitch over the wire protocol have access to the full functionality of the MongoDB Service. However, Stitch does not support all operations and features available in standard tools and clients. For details, see MongoDB Service Limitations.
Usage¶
Connect to Stitch with a Connection String¶
To connect to Stitch over the wire protocol, pass a URL-encoded Stitch connection string when you create a client, just as you would with a regular connection string.
- Mongo Shell
- Python
- C++11
- Perl
Perform CRUD Operations¶
When you’re connected to Stitch over the wire protocol you can use standard MongoDB CRUD operations. Stitch applies role-based data access rules to all queries in the context of the authenticated user specified in the connection string credentials.
- Mongo Shell
- Python
- C++11
- Perl
Call a Function¶
You can call functions using the callFunction
database command.
Command | Description | Prototype |
---|---|---|
|
Calls the specified function and returns any result. |
- Mongo Shell
- Python
- C++11
- Perl
Call a Service Function¶
You can call service actions using the callServiceFunction
database
command.
Command | Description | Prototype |
---|---|---|
|
Calls the specified service action and returns any result. |
- Mongo Shell
- Python
- C++11
- Perl
Get the Logged In User’s Data¶
You can get the user object for the authenticated user
using the userProfile
database command.
Command | Description | Prototype |
---|---|---|
|
Returns the user object for the authenticated user. |
- Mongo Shell
- Python
- C++11
- Perl