Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 11.1   11.2   11.3   11.4   11.5   12.0   12.1   12.2   12.3   12.4    Statistic    FMM    Blog  

MongoDB.SetURI

Sets the URI.

Component Version macOS Windows Linux Server iOS SDK
MongoDB 12.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "MongoDB.SetURI"; MongoDBRef; URI )   More

Parameters

Parameter Description Example
MongoDBRef The reference number for the mongo connection. $MongoDB
URI The URI to use. "mongodb://localhost/"

Result

Returns OK or error.

Description

Sets the URI.
Parses a string containing a MongoDB style URI connection string.
Returns an error in case of a parsing error.

Examples of some valid MongoDB connection strings can be seen below.

  • "mongodb://localhost/"
  • "mongodb://localhost/?replicaSet=myreplset"
  • "mongodb://myuser:mypass@localhost/"
  • "mongodb://kerberosuser%40EXAMPLE.COM@example.com/?authMechanism=GSSAPI"
  • "mongodb://[::1]:27017/"
  • "mongodb://10.0.0.1:27017,10.0.0.1:27018,[::1]:27019/?tls=true"
  • "mongodb://%2Ftmp%2Fmongodb-27017.sock"
  • "mongodb://user:pass@%2Ftmp%2Fmongodb-27017.sock"
  • "mongodb://localhost,[::1]/mydb?authSource=mydb"

If you like to use a SSH tunnel, you can create a tunnel with our SSH functions. Use SSH.Tunnel.Run to connect a local port with your remote server and the destination (usually port 27017). Then connect to localhost with the local port.

Examples

Connect to local server:

Set Variable [ $r ; Value: MBS( "MongoDB.SetURI"; $Mongo; "mongodb://localhost/" ) ]

See also

Example Databases

Created 22nd May 2022, last changed 25th June 2022


MongoDB.SetPassword - MongoDB.SetUserName

Feedback: Report problem or ask question.


Start Chat