MongoDB.Command
---------------

Execute a command on the server.

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

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

**MBS**( **"MongoDB.Command"** /\* Execute a command on the server. \*/  
**$MongoDBRef**; /\* The reference number for the mongo connection. e.g. $MongoDB \*/   
**$Command**; /\* The command as JSON. e.g. "{ \\"hello\\": 1 }" \*/   
**$Options**) /\* Optional; JSON with options. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| MongoDBRef | The reference number for the mongo connection. | $MongoDB |  |
| Command | The command as JSON. | "{ \\"hello\\": 1 }" |  |
| Options | JSON with options. |  | Optional |

### Result

Returns JSON or error.

### Description

Execute a command on the server.  
Please open relevant collection first with [MongoDB.OpenCollection](MongoDBOpenCollection.md).  
Consult the MongoDB Manual entry on Database Commands for each command’s arguments.  
### Examples

Run Hello command:

 Set Variable \[ $json ; Value: MBS ( "MongoDB.Command"; $Mongo ; "{ \\"hello\\": 1 }") \]   
Show Custom Dialog \[ "Record" ; $json \]  
### See also

- [MongoDB.ClientCommand](MongoDBClientCommand.md)
- [MongoDB.OpenCollection](MongoDBOpenCollection.md)

### Release notes

- **Version 13.1**
    - Added [MongoDB.Command](https://www.mbsplugins.eu/MongoDBCommand.shtml), [MongoDB.AggregateDatabase](https://www.mbsplugins.eu/MongoDBAggregateDatabase.shtml) and [MongoDB.AggregateCollection](https://www.mbsplugins.eu/MongoDBAggregateCollection.shtml) functions.

### Example Databases

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

### Blog Entries

- [MBS FileMaker Plugin, version 13.1pr2](https://www.mbsplugins.de/archive/2023-02-06/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

Created 3th February 2023 , last changed 3th February 2023

  
[MongoDB.CollectionNames](MongoDBCollectionNames.md) - [MongoDB.CommitTransaction](MongoDBCommitTransaction.md)

[HTML Version](MongoDBCommand.shtml)