MongoDB.DatabaseCommand
-----------------------

Creates a collection in the database.

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

MBS( "MongoDB.DatabaseCommand"; MongoDBRef; Command { ; Options } ) 

**MBS**( **"MongoDB.DatabaseCommand";** /\* Creates a collection in the database. \*/  
**$MongoDBRef**; /\* The reference number for the mongo connection.e.g. $MongoDB \*/   
**$Command**; /\* The comand to run as JSON.e.g. "{\\"ping\\": 1}" \*/   
**$Options**) /\* Optional; Options as JSON. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| MongoDBRef | The reference number for the mongo connection. | $MongoDB |  |
| Command | The comand to run as JSON. | "{\\"ping\\": 1}" |  |
| Options | Options as JSON. |  | Optional |

### Result

Returns JSON or error.

### Description

Creates a collection in the database.  
If no write concern is provided in opts, the database’s write concern is used.  
For a list of all options, see the MongoDB Manual entry on the create command.  
Raises an exception in case of an error.  
### Examples

Ping the server:

 Set Variable \[ $Mongo ; Value: MBS ( "[MongoDB.New](MongoDBNew.md)" ) \]   
Set Variable \[ $r ; Value: MBS ( "[MongoDB.SetURI](MongoDBSetURI.md)"; $Mongo ; "mongodb://localhost/" ) \]   
Set Variable \[ $r ; Value: MBS ( "[MongoDB.Connect](MongoDBConnect.md)"; $Mongo ) \]   
Set Variable \[ $r ; Value: MBS ( "[MongoDB.OpenDatabase](MongoDBOpenDatabase.md)"; $Mongo ; "local" ) \]   
Set Variable \[ $r ; Value: MBS ( "[MongoDB.OpenCollection](MongoDBOpenCollection.md)"; $Mongo ; "test" ) \]   
\# send a ping command   
Set Variable \[ $r ; Value: MBS ( "MongoDB.DatabaseCommand"; $Mongo ; "{\\"ping\\": 1}") \]   
Show Custom Dialog \[ "Result" ; $r \]   
Set Variable \[ $r ; Value: MBS ( "[MongoDB.Release](MongoDBRelease.md)"; $Mongo ) \]  
### See also

- [MongoDB.Connect](MongoDBConnect.md)
- [MongoDB.DatabasesNames](MongoDBDatabasesNames.md)
- [MongoDB.New](MongoDBNew.md)
- [MongoDB.OpenCollection](MongoDBOpenCollection.md)
- [MongoDB.OpenDatabase](MongoDBOpenDatabase.md)
- [MongoDB.Release](MongoDBRelease.md)
- [MongoDB.SetURI](MongoDBSetURI.md)

### Example Databases

- [MongoDB/MongoDB Blog](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/MongoDB/MongoDB%20Blog.shtml#31ScriptAnchor_)

This function checks for a license.

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

  
[MongoDB.CursorSetMaxAwaitTimeMS](MongoDBCursorSetMaxAwaitTimeMS.md) - [MongoDB.DatabasesNames](MongoDBDatabasesNames.md)

[HTML Version](MongoDBDatabaseCommand.shtml)