MongoDB.OpenDatabase
--------------------

Opens the given database.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [MongoDB](component_MongoDB.md) | [12.3](newinversion123.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "MongoDB.OpenDatabase"; MongoDBRef; DatabaseName ) 

**MBS**( **"MongoDB.OpenDatabase";** /\* Opens the given database. \*/  
**$MongoDBRef**; /\* The reference number for the mongo connection.e.g. $MongoDB \*/   
**$DatabaseName**) /\* The name of the database.e.g. "test" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| MongoDBRef | The reference number for the mongo connection. | $MongoDB |
| DatabaseName | The name of the database. | "test" |

### Result

Returns OK or error.

### Description

Opens the given database.  
Databases are automatically created on the MongoDB server upon insertion of the first document into a collection. There is no need to create a database manually.  
### Examples

Open database:

 Set Variable \[ $r ; Value: MBS ( "MongoDB.OpenDatabase"; $Mongo ; test::Database Name ) \]   
If \[ MBS ("IsError") \]   
 Set Variable \[ $x ; Value: MBS ( "[MongoDB.Release](MongoDBRelease.md)"; $Mongo ) \]   
 Show Custom Dialog \[ "Failed to open database." ; $r \]   
 Exit Script \[ Text Result: \]   
End If  
### See also

- [IsError](IsError.md)
- [MongoDB.DatabaseCommand](MongoDBDatabaseCommand.md)
- [MongoDB.Find](MongoDBFind.md)
- [MongoDB.FindCollections](MongoDBFindCollections.md)
- [MongoDB.FindDatabases](MongoDBFindDatabases.md)
- [MongoDB.InsertOne](MongoDBInsertOne.md)
- [MongoDB.Release](MongoDBRelease.md)
- [MongoDB.SetDatabase](MongoDBSetDatabase.md)
- [MongoDB.UpdateMany](MongoDBUpdateMany.md)
- [MongoDB.WatchDatabase](MongoDBWatchDatabase.md)

### Example Databases

- [MongoDB/MongoDB Audit](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/MongoDB/MongoDB%20Audit.shtml#1ScriptAnchor_)
- [MongoDB/MongoDB Blog](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/MongoDB/MongoDB%20Blog.shtml#4ScriptAnchor_)
- [MongoDB/MongoDB Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/MongoDB/MongoDB%20Test.shtml#2ScriptAnchor_)

### Blog Entries

- [Watch MongoDB Database](https://www.mbsplugins.de/archive/2023-11-04/Watch_MongoDB_Database/monkeybreadsoftware_blog_filemaker)
- [FileMaker and MongoDB](https://www.mbsplugins.de/archive/2023-03-20/FileMaker_and_MongoDB/monkeybreadsoftware_blog_filemaker)
- [New MongoDB Example](https://www.mbsplugins.de/archive/2022-07-25/New_MongoDB_Example/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2025, Seite 24](https://filemaker-magazin.de/neuigkeit/4282-Appetithappen-FMM_202501)

This function checks for a license.

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

  
[MongoDB.OpenCollection](MongoDBOpenCollection.md) - [MongoDB.OpenDefaultDatabase](MongoDBOpenDefaultDatabase.md)

[HTML Version](MongoDBOpenDatabase.shtml)