MongoDB.FindCollections
-----------------------

Fetches a cursor containing documents, each corresponding to a collection on this database.

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

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

**MBS**( **"MongoDB.FindCollections";** /\* Fetches a cursor containing documents, each corresponding to a collection on this database. \*/  
**$MongoDBRef**; /\* The reference number for the mongo connection.e.g. $MongoDB \*/   
**$Options**) /\* Optional; JSON with options. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| MongoDBRef | The reference number for the mongo connection. | $MongoDB |  |
| Options | JSON with options. |  | Optional |

### Result

Returns OK or error.

### Description

Fetches a cursor containing documents, each corresponding to a collection on this database.  
Sets the current cursor.  
### Examples

Find records for collections:

 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" ) \]   
\# get cursor for records describing collections   
Set Variable \[ $r ; Value: MBS ( "MongoDB.FindCollections"; $Mongo ) \]   
\# loop over records and show each   
Loop  
 Set Variable \[ $json ; Value: MBS ( "[MongoDB.CursorNext](MongoDBCursorNext.md)"; $Mongo ) \]   
 Exit Loop If \[ MBS ("IsError") // some error like connection dropped \]   
 Exit Loop If \[ Length ( $json ) = 0 // end of cursor \]   
 Show Custom Dialog \[ "Record" ; $json \]   
End Loop  
Set Variable \[ $r ; Value: MBS ( "[MongoDB.Release](MongoDBRelease.md)"; $Mongo ) \]  
### See also

- [IsError](IsError.md)
- [MongoDB.Connect](MongoDBConnect.md)
- [MongoDB.CursorNext](MongoDBCursorNext.md)
- [MongoDB.Find](MongoDBFind.md)
- [MongoDB.HasCollection](MongoDBHasCollection.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#27ScriptAnchor_)
- [MongoDB/MongoDB Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/MongoDB/MongoDB%20Test.shtml#3ScriptAnchor_)

### 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 24th May 2022

  
[MongoDB.Find](MongoDBFind.md) - [MongoDB.FindDatabases](MongoDBFindDatabases.md)

[HTML Version](MongoDBFindCollections.shtml)