Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

MBS FileMaker Plugin Example Databases

MongoDB Test

All examples are included with download of MBS FileMaker Plugin.

MongoDB Test.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts15
Value Lists0
Custom Functions0
Custom Menus24
File Options
Default custom menu set[Standard FileMaker Menus]
When opening file
Minimum allowed version12.0
Login usingAccount Name; Account= Admin
Allow user to save passwordOff
Require iOS passcodeOff
Switch to layoutOff
Hide all toolbarsOff
Script triggers
OnFirstWindowOpenOff
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
test
9 fields defined, 1 record
test

Fields

Table Name: test - 9 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
PrimaryKeyNormal, TextAuto-Enter:
  • Context table: test
    Calculation: Get( UUID )
Validation:
  • Only during data entry
  • Not empty
  • Unique
  • Strict validation
Storage:
  • Repetitions: 1
  • Indexing: Minimal
  • Automatically create indexes as needed
  • Index Language: Unicode Raw
Unique identifier of each record in this table
          CreationTimestampNormal, TimestampAuto-Enter:
          • Creation timestamp
          Validation:
          • Only during data entry
          • Strict data type: 4 digit year
          • Not empty
          • Strict validation
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: English
          Date and time each record was created
                  CreatedByNormal, TextAuto-Enter:
                  • Creation account name
                  Validation:
                  • Only during data entry
                  • Not empty
                  • Strict validation
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: English
                  Account name of the user who created each record
                          ModificationTimestampNormal, TimestampAuto-Enter:
                          • Modification timestamp
                          Validation:
                          • Only during data entry
                          • Strict data type: 4 digit year
                          • Not empty
                          • Strict validation
                          Storage:
                          • Repetitions: 1
                          • Indexing: None
                          • Automatically create indexes as needed
                          • Index Language: English
                          Date and time each record was last modified
                                  ModifiedByNormal, TextAuto-Enter:
                                  • Modification account name
                                  Validation:
                                  • Only during data entry
                                  • Not empty
                                  • Strict validation
                                  Storage:
                                  • Repetitions: 1
                                  • Indexing: None
                                  • Automatically create indexes as needed
                                  • Index Language: English
                                  Account name of the user who last modified each record
                                          MongoDB URLNormal, TextAuto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1
                                          • Indexing: None
                                          • Automatically create indexes as needed
                                          • Index Language: English
                                              Database NameNormal, TextAuto-Enter:
                                              • Allow editing
                                              Validation:
                                              • Only during data entry
                                              Storage:
                                              • Repetitions: 1
                                              • Indexing: None
                                              • Automatically create indexes as needed
                                              • Index Language: English
                                                  Collection NameNormal, TextAuto-Enter:
                                                  • Allow editing
                                                  Validation:
                                                  • Only during data entry
                                                  Storage:
                                                  • Repetitions: 1
                                                  • Indexing: None
                                                  • Automatically create indexes as needed
                                                  • Index Language: English
                                                      Insert JSONNormal, TextAuto-Enter:
                                                      • Allow editing
                                                      • Context table: test
                                                        Calculation: // colorize it if needed Let ([ r = MBS("JSON.Colorize"; Self); e= MBS("IsError")]; If(e = 0; r; Self) )
                                                      Validation:
                                                      • Only during data entry
                                                      Storage:
                                                      • Repetitions: 1
                                                      • Indexing: None
                                                      • Automatically create indexes as needed
                                                      • Index Language: English

                                                          Layout Objects: test

                                                          Regular Fields

                                                          Field Name: test::MongoDB URL
                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                          • Top: 114 pt
                                                          • Left: 138 pt
                                                          • Bottom: 146 pt
                                                          • Right: 391 pt
                                                          • Anchoring: Left, Top
                                                          Field Format:
                                                          • Edit Box
                                                          Field Behavior:
                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                          • Touch keyboard type: Default for Data Type
                                                          • Go to next field using: Tab key
                                                          Yes

                                                          Field Name: test::Database Name
                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                          • Top: 150 pt
                                                          • Left: 138 pt
                                                          • Bottom: 182 pt
                                                          • Right: 391 pt
                                                          • Anchoring: Left, Top
                                                          Field Format:
                                                          • Edit Box
                                                          Field Behavior:
                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                          • Touch keyboard type: Default for Data Type
                                                          • Go to next field using: Tab key
                                                          Yes

                                                          Field Name: test::Collection Name
                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                          • Top: 186 pt
                                                          • Left: 138 pt
                                                          • Bottom: 218 pt
                                                          • Right: 391 pt
                                                          • Anchoring: Left, Top
                                                          Field Format:
                                                          • Edit Box
                                                          Field Behavior:
                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                          • Touch keyboard type: Default for Data Type
                                                          • Go to next field using: Tab key
                                                          Yes

                                                          Field Name: test::Insert JSON
                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                          • Top: 222 pt
                                                          • Left: 138 pt
                                                          • Bottom: 333 pt
                                                          • Right: 391 pt
                                                          • Anchoring: Left, Top
                                                          Field Format:
                                                          • Edit Box
                                                          Field Behavior:
                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                          • Touch keyboard type: Default for Data Type
                                                          • Go to next field using: Tab key
                                                          Yes

                                                          Buttons

                                                          Button PropertiesCoordinatesScript/Script Step
                                                            Type:
                                                          • Text: Show Databases
                                                          • Top: 114 pt
                                                          • Left: 429 pt
                                                          • Bottom: 150 pt
                                                          • Right: 653 pt
                                                          • Anchoring: Left, Top
                                                          Perform Script [ “Query database names” ]

                                                          Scripts:


                                                          Button PropertiesCoordinatesScript/Script Step
                                                            Type:
                                                          • Text: Show Collections
                                                          • Top: 159 pt
                                                          • Left: 429 pt
                                                          • Bottom: 195 pt
                                                          • Right: 653 pt
                                                          • Anchoring: Left, Top
                                                          Perform Script [ “Query collection names” ]

                                                          Scripts:


                                                          Button PropertiesCoordinatesScript/Script Step
                                                            Type:
                                                          • Text: Insert Record
                                                          • Top: 294 pt
                                                          • Left: 429 pt
                                                          • Bottom: 330 pt
                                                          • Right: 653 pt
                                                          • Anchoring: Left, Top
                                                          Perform Script [ “Insert” ]

                                                          Scripts:


                                                          Button PropertiesCoordinatesScript/Script Step
                                                            Type:
                                                          • Text: Show Collection Records
                                                          • Top: 204 pt
                                                          • Left: 429 pt
                                                          • Bottom: 240 pt
                                                          • Right: 653 pt
                                                          • Anchoring: Left, Top
                                                          Perform Script [ “Find Collections” ]

                                                          Scripts:


                                                          Button PropertiesCoordinatesScript/Script Step
                                                            Type:
                                                          • Text: Show Database Records
                                                          • Top: 246 pt
                                                          • Left: 429 pt
                                                          • Bottom: 282 pt
                                                          • Right: 653 pt
                                                          • Anchoring: Left, Top
                                                          Perform Script [ “Find Databases” ]

                                                          Scripts:


                                                          Script Hierarchy

                                                          Connect
                                                          Query database names
                                                          Query collection names
                                                          Find Collections
                                                          Find Databases
                                                          Find
                                                          Insert
                                                          Update one
                                                          Update many
                                                          Replace one
                                                          List Keys in Collection
                                                          Insert with transaction
                                                          List Local Sessions
                                                          Run Hello Command
                                                          On Window Transaction

                                                          Next Script: [Query database names]
                                                          Script NameConnect
                                                          Run script with full access privilegesOff
                                                          Include In MenuYes
                                                          Layouts that use this script
                                                            Scripts that use this script
                                                            Script Definition
                                                            Script Steps
                                                            • Set Variable [ $Mongo; Value:MBS( "MongoDB.New" ) ]
                                                            • If [ MBS("IsError") ]
                                                            • Show Custom Dialog [ Title: "Failed to create new MongoDB object"; Message: $Mongo; Default Button: “OK”, Commit: “Yes” ]
                                                            • Exit Script [ ]
                                                            • End If
                                                            • Set Variable [ $r; Value:MBS( "MongoDB.SetURI"; $Mongo; test::MongoDB URL ) ]
                                                            • If [ MBS("IsError") ]
                                                            • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                            • Show Custom Dialog [ Title: "Failed to parse connection string."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                            • Exit Script [ ]
                                                            • End If
                                                            • Set Variable [ $r; Value:MBS( "MongoDB.Connect"; $Mongo) ]
                                                            • If [ MBS("IsError") ]
                                                            • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                            • Show Custom Dialog [ Title: "Failed to connect to MongoDB."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                            • Exit Script [ ]
                                                            • End If
                                                            • #success
                                                            • Exit Script [ Result: $Mongo ]
                                                            Fields used in this script
                                                            Scripts used in this script
                                                              Layouts used in this script
                                                                Tables used in this script
                                                                Table occurrences used by this script
                                                                Custom Functions used by this script
                                                                  Custom menu set used by this script

                                                                    Previous Script: [Connect]Next Script: [Query collection names]
                                                                    Script NameQuery database names
                                                                    Run script with full access privilegesOff
                                                                    Include In MenuYes
                                                                    Layouts that use this script
                                                                    Scripts that use this script
                                                                      Script Definition
                                                                      Script Steps
                                                                      • Perform Script [ “Connect” ]
                                                                      • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                      • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                      • Exit Script [ ]
                                                                      • End If
                                                                      • Set Variable [ $list; Value:MBS( "MongoDB.DatabasesNames"; $Mongo ) ]
                                                                      • Show Custom Dialog [ Title: "Databases"; Message: $list; Default Button: “OK”, Commit: “Yes” ]
                                                                      • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                      Fields used in this script
                                                                        Scripts used in this script
                                                                        Layouts used in this script
                                                                          Tables used in this script
                                                                            Table occurrences used by this script
                                                                              Custom Functions used by this script
                                                                                Custom menu set used by this script

                                                                                  Previous Script: [Query database names]Next Script: [Find Collections]
                                                                                  Script NameQuery collection names
                                                                                  Run script with full access privilegesOff
                                                                                  Include In MenuYes
                                                                                  Layouts that use this script
                                                                                  Scripts that use this script
                                                                                    Script Definition
                                                                                    Script Steps
                                                                                    • Perform Script [ “Connect” ]
                                                                                    • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                    • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                    • If [ MBS("IsError") ]
                                                                                    • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                    • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $list; Value:MBS( "MongoDB.CollectionNames"; $Mongo ) ]
                                                                                    • Show Custom Dialog [ Title: "Collections"; Message: $list; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                    Fields used in this script
                                                                                    Scripts used in this script
                                                                                    Layouts used in this script
                                                                                      Tables used in this script
                                                                                      Table occurrences used by this script
                                                                                      Custom Functions used by this script
                                                                                        Custom menu set used by this script

                                                                                          Previous Script: [Query collection names]Next Script: [Find Databases]
                                                                                          Script NameFind Collections
                                                                                          Run script with full access privilegesOff
                                                                                          Include In MenuYes
                                                                                          Layouts that use this script
                                                                                          Scripts that use this script
                                                                                            Script Definition
                                                                                            Script Steps
                                                                                            • Perform Script [ “Connect” ]
                                                                                            • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                            • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                            • Exit Script [ ]
                                                                                            • End If
                                                                                            • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                            • If [ MBS("IsError") ]
                                                                                            • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                            • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                            • Exit Script [ ]
                                                                                            • End If
                                                                                            • Set Variable [ $r; Value:MBS( "MongoDB.OpenCollection"; $Mongo; test::Collection Name ) ]
                                                                                            • If [ MBS("IsError") ]
                                                                                            • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                            • Show Custom Dialog [ Title: "Failed to open collection."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                            • Exit Script [ ]
                                                                                            • End If
                                                                                            • #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"; $Mongo) ]
                                                                                            • Exit Loop If [ MBS("IsError") // some error like connection dropped ]
                                                                                            • Exit Loop If [ Length ( $json ) = 0 // end of cursor ]
                                                                                            • Show Custom Dialog [ Title: "Record"; Message: $json; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                                                            • Exit Loop If [ Get(LastMessageChoice) = 2 ]
                                                                                            • End Loop
                                                                                            • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                            Fields used in this script
                                                                                            Scripts used in this script
                                                                                            Layouts used in this script
                                                                                              Tables used in this script
                                                                                              Table occurrences used by this script
                                                                                              Custom Functions used by this script
                                                                                                Custom menu set used by this script

                                                                                                  Previous Script: [Find Collections]Next Script: [Find]
                                                                                                  Script NameFind Databases
                                                                                                  Run script with full access privilegesOff
                                                                                                  Include In MenuYes
                                                                                                  Layouts that use this script
                                                                                                  Scripts that use this script
                                                                                                    Script Definition
                                                                                                    Script Steps
                                                                                                    • Perform Script [ “Connect” ]
                                                                                                    • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                                    • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                                    • Exit Script [ ]
                                                                                                    • End If
                                                                                                    • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                                    • If [ MBS("IsError") ]
                                                                                                    • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                    • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                    • Exit Script [ ]
                                                                                                    • End If
                                                                                                    • Set Variable [ $r; Value:MBS( "MongoDB.OpenCollection"; $Mongo; test::Collection Name ) ]
                                                                                                    • If [ MBS("IsError") ]
                                                                                                    • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                    • Show Custom Dialog [ Title: "Failed to open collection."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                    • Exit Script [ ]
                                                                                                    • End If
                                                                                                    • #get cursor for records describing databases
                                                                                                    • Set Variable [ $r; Value:MBS( "MongoDB.FindDatabases"; $Mongo) ]
                                                                                                    • #loop over records and show each
                                                                                                    • Loop
                                                                                                    • Set Variable [ $json; Value:MBS( "MongoDB.CursorNext"; $Mongo) ]
                                                                                                    • Exit Loop If [ MBS("IsError") // some error like connection dropped ]
                                                                                                    • Exit Loop If [ Length ( $json ) = 0 // end of cursor ]
                                                                                                    • Show Custom Dialog [ Title: "Record"; Message: $json; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                                                                    • Exit Loop If [ Get(LastMessageChoice) = 2 ]
                                                                                                    • End Loop
                                                                                                    • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                    Fields used in this script
                                                                                                    Scripts used in this script
                                                                                                    Layouts used in this script
                                                                                                      Tables used in this script
                                                                                                      Table occurrences used by this script
                                                                                                      Custom Functions used by this script
                                                                                                        Custom menu set used by this script

                                                                                                          Previous Script: [Find Databases]Next Script: [Insert]
                                                                                                          Script NameFind
                                                                                                          Run script with full access privilegesOff
                                                                                                          Include In MenuYes
                                                                                                          Layouts that use this script
                                                                                                            Scripts that use this script
                                                                                                              Script Definition
                                                                                                              Script Steps
                                                                                                              • Perform Script [ “Connect” ]
                                                                                                              • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                                              • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                                              • Exit Script [ ]
                                                                                                              • End If
                                                                                                              • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                                              • If [ MBS("IsError") ]
                                                                                                              • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                              • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                              • Exit Script [ ]
                                                                                                              • End If
                                                                                                              • Set Variable [ $r; Value:MBS( "MongoDB.OpenCollection"; $Mongo; test::Collection Name ) ]
                                                                                                              • If [ MBS("IsError") ]
                                                                                                              • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                              • Show Custom Dialog [ Title: "Failed to open collection."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                              • Exit Script [ ]
                                                                                                              • End If
                                                                                                              • #get cursor for records describing collections
                                                                                                              • Set Variable [ $r; Value:MBS( "MongoDB.Find"; $Mongo; "{\"OtherField\": { \"$gt\" : 123}}") ]
                                                                                                              • If [ MBS("ISError") ]
                                                                                                              • Show Custom Dialog [ Title: "Failed to find"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                              • Else
                                                                                                              • #loop over records and show each
                                                                                                              • Loop
                                                                                                              • Set Variable [ $json; Value:MBS( "MongoDB.CursorNext"; $Mongo) ]
                                                                                                              • Exit Loop If [ MBS("IsError") // some error like connection dropped ]
                                                                                                              • Exit Loop If [ Length ( $json ) = 0 // end of cursor ]
                                                                                                              • Show Custom Dialog [ Title: "Record"; Message: $json; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                                                                              • Exit Loop If [ Get(LastMessageChoice) = 2 ]
                                                                                                              • End Loop
                                                                                                              • End If
                                                                                                              • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                              Fields used in this script
                                                                                                              Scripts used in this script
                                                                                                              Layouts used in this script
                                                                                                                Tables used in this script
                                                                                                                Table occurrences used by this script
                                                                                                                Custom Functions used by this script
                                                                                                                  Custom menu set used by this script

                                                                                                                    Previous Script: [Find]Next Script: [Update one]
                                                                                                                    Script NameInsert
                                                                                                                    Run script with full access privilegesOff
                                                                                                                    Include In MenuYes
                                                                                                                    Layouts that use this script
                                                                                                                    Scripts that use this script
                                                                                                                      Script Definition
                                                                                                                      Script Steps
                                                                                                                      • Perform Script [ “Connect” ]
                                                                                                                      • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                                                      • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                                                      • Exit Script [ ]
                                                                                                                      • End If
                                                                                                                      • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                                                      • If [ MBS("IsError") ]
                                                                                                                      • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                      • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                      • Exit Script [ ]
                                                                                                                      • End If
                                                                                                                      • Set Variable [ $r; Value:MBS( "MongoDB.OpenCollection"; $Mongo; test::Collection Name ) ]
                                                                                                                      • If [ MBS("IsError") ]
                                                                                                                      • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                      • Show Custom Dialog [ Title: "Failed to open collection."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                      • Exit Script [ ]
                                                                                                                      • End If
                                                                                                                      • #insert a record
                                                                                                                      • Set Variable [ $r; Value:MBS( "MongoDB.InsertOne"; $Mongo; test::Insert JSON) ]
                                                                                                                      • Show Custom Dialog [ Title: "Result"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                      • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                      Fields used in this script
                                                                                                                      Scripts used in this script
                                                                                                                      Layouts used in this script
                                                                                                                        Tables used in this script
                                                                                                                        Table occurrences used by this script
                                                                                                                        Custom Functions used by this script
                                                                                                                          Custom menu set used by this script

                                                                                                                            Previous Script: [Insert]Next Script: [Update many]
                                                                                                                            Script NameUpdate one
                                                                                                                            Run script with full access privilegesOff
                                                                                                                            Include In MenuYes
                                                                                                                            Layouts that use this script
                                                                                                                              Scripts that use this script
                                                                                                                                Script Definition
                                                                                                                                Script Steps
                                                                                                                                • Perform Script [ “Connect” ]
                                                                                                                                • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                                                                • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                                                                • Exit Script [ ]
                                                                                                                                • End If
                                                                                                                                • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                                                                • If [ MBS("IsError") ]
                                                                                                                                • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                • Exit Script [ ]
                                                                                                                                • End If
                                                                                                                                • Set Variable [ $r; Value:MBS( "MongoDB.OpenCollection"; $Mongo; test::Collection Name ) ]
                                                                                                                                • If [ MBS("IsError") ]
                                                                                                                                • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                • Show Custom Dialog [ Title: "Failed to open collection."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                • Exit Script [ ]
                                                                                                                                • End If
                                                                                                                                • #update one record by setting a new field
                                                                                                                                • Set Variable [ $r; Value:MBS( "MongoDB.UpdateOne"; $Mongo; "{\"Hello\": \"World\"}"; "{\"$set\": {\"OtherField\": 123}}") ]
                                                                                                                                • Show Custom Dialog [ Title: "Result"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                Fields used in this script
                                                                                                                                Scripts used in this script
                                                                                                                                Layouts used in this script
                                                                                                                                  Tables used in this script
                                                                                                                                  Table occurrences used by this script
                                                                                                                                  Custom Functions used by this script
                                                                                                                                    Custom menu set used by this script

                                                                                                                                      Previous Script: [Update one]Next Script: [Replace one]
                                                                                                                                      Script NameUpdate many
                                                                                                                                      Run script with full access privilegesOff
                                                                                                                                      Include In MenuYes
                                                                                                                                      Layouts that use this script
                                                                                                                                        Scripts that use this script
                                                                                                                                          Script Definition
                                                                                                                                          Script Steps
                                                                                                                                          • Perform Script [ “Connect” ]
                                                                                                                                          • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                                                                          • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                                                                          • Exit Script [ ]
                                                                                                                                          • End If
                                                                                                                                          • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                                                                          • If [ MBS("IsError") ]
                                                                                                                                          • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                          • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                          • Exit Script [ ]
                                                                                                                                          • End If
                                                                                                                                          • Set Variable [ $r; Value:MBS( "MongoDB.OpenCollection"; $Mongo; test::Collection Name ) ]
                                                                                                                                          • If [ MBS("IsError") ]
                                                                                                                                          • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                          • Show Custom Dialog [ Title: "Failed to open collection."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                          • Exit Script [ ]
                                                                                                                                          • End If
                                                                                                                                          • #update a lot of records by setting a new field
                                                                                                                                          • Set Variable [ $r; Value:MBS( "MongoDB.UpdateMany"; $Mongo; "{\"Hello\": \"World\"}"; "{\"$set\": {\"OtherField\": 123}}") ]
                                                                                                                                          • Show Custom Dialog [ Title: "Result"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                          • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                          Fields used in this script
                                                                                                                                          Scripts used in this script
                                                                                                                                          Layouts used in this script
                                                                                                                                            Tables used in this script
                                                                                                                                            Table occurrences used by this script
                                                                                                                                            Custom Functions used by this script
                                                                                                                                              Custom menu set used by this script

                                                                                                                                                Previous Script: [Update many]Next Script: [List Keys in Collection]
                                                                                                                                                Script NameReplace one
                                                                                                                                                Run script with full access privilegesOff
                                                                                                                                                Include In MenuYes
                                                                                                                                                Layouts that use this script
                                                                                                                                                  Scripts that use this script
                                                                                                                                                    Script Definition
                                                                                                                                                    Script Steps
                                                                                                                                                    • Perform Script [ “Connect” ]
                                                                                                                                                    • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                                                                                    • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                                                                                    • Exit Script [ ]
                                                                                                                                                    • End If
                                                                                                                                                    • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                                                                                    • If [ MBS("IsError") ]
                                                                                                                                                    • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                    • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                    • Exit Script [ ]
                                                                                                                                                    • End If
                                                                                                                                                    • Set Variable [ $r; Value:MBS( "MongoDB.OpenCollection"; $Mongo; test::Collection Name ) ]
                                                                                                                                                    • If [ MBS("IsError") ]
                                                                                                                                                    • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                    • Show Custom Dialog [ Title: "Failed to open collection."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                    • Exit Script [ ]
                                                                                                                                                    • End If
                                                                                                                                                    • #replace a record with a new JSON
                                                                                                                                                    • Set Variable [ $r; Value:MBS( "MongoDB.ReplaceOne"; $Mongo; "{\"Hello\": \"World\"}"; "{\"Hello\": \"World\", \"OtherField\": 123}") ]
                                                                                                                                                    • Show Custom Dialog [ Title: "Result"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                    • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                    Fields used in this script
                                                                                                                                                    Scripts used in this script
                                                                                                                                                    Layouts used in this script
                                                                                                                                                      Tables used in this script
                                                                                                                                                      Table occurrences used by this script
                                                                                                                                                      Custom Functions used by this script
                                                                                                                                                        Custom menu set used by this script

                                                                                                                                                          Previous Script: [Replace one]Next Script: [Insert with transaction]
                                                                                                                                                          Script NameList Keys in Collection
                                                                                                                                                          Run script with full access privilegesOff
                                                                                                                                                          Include In MenuYes
                                                                                                                                                          Layouts that use this script
                                                                                                                                                            Scripts that use this script
                                                                                                                                                              Script Definition
                                                                                                                                                              Script Steps
                                                                                                                                                              • Perform Script [ “Connect” ]
                                                                                                                                                              • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                                                                                              • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                                                                                              • Exit Script [ ]
                                                                                                                                                              • End If
                                                                                                                                                              • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                                                                                              • If [ MBS("IsError") ]
                                                                                                                                                              • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                              • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                              • Exit Script [ ]
                                                                                                                                                              • End If
                                                                                                                                                              • Set Variable [ $r; Value:MBS( "MongoDB.OpenCollection"; $Mongo; test::Collection Name ) ]
                                                                                                                                                              • If [ MBS("IsError") ]
                                                                                                                                                              • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                              • Show Custom Dialog [ Title: "Failed to open collection."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                              • Exit Script [ ]
                                                                                                                                                              • End If
                                                                                                                                                              • #Query list of keys in the current collection:
                                                                                                                                                              • Set Variable [ $r; Value:MBS( "MongoDB.Keys"; $Mongo) ]
                                                                                                                                                              • Show Custom Dialog [ Title: "Key Names"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                              • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                              Fields used in this script
                                                                                                                                                              Scripts used in this script
                                                                                                                                                              Layouts used in this script
                                                                                                                                                                Tables used in this script
                                                                                                                                                                Table occurrences used by this script
                                                                                                                                                                Custom Functions used by this script
                                                                                                                                                                  Custom menu set used by this script

                                                                                                                                                                    Previous Script: [List Keys in Collection]Next Script: [List Local Sessions]
                                                                                                                                                                    Script NameInsert with transaction
                                                                                                                                                                    Run script with full access privilegesOff
                                                                                                                                                                    Include In MenuYes
                                                                                                                                                                    Layouts that use this script
                                                                                                                                                                      Scripts that use this script
                                                                                                                                                                        Script Definition
                                                                                                                                                                        Script Steps
                                                                                                                                                                        • Perform Script [ “Connect” ]
                                                                                                                                                                        • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                                                                                                        • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                                                                                                        • Exit Script [ ]
                                                                                                                                                                        • End If
                                                                                                                                                                        • Set Variable [ $r; Value:MBS( "MongoDB.StartTransaction"; $Mongo) ]
                                                                                                                                                                        • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                                                                                                        • If [ MBS("IsError") ]
                                                                                                                                                                        • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                                        • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                        • Exit Script [ ]
                                                                                                                                                                        • End If
                                                                                                                                                                        • Set Variable [ $r; Value:MBS( "MongoDB.OpenCollection"; $Mongo; test::Collection Name ) ]
                                                                                                                                                                        • If [ MBS("IsError") ]
                                                                                                                                                                        • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                                        • Show Custom Dialog [ Title: "Failed to open collection."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                        • Exit Script [ ]
                                                                                                                                                                        • End If
                                                                                                                                                                        • #Open connection first, open database and connection
                                                                                                                                                                        • Show Custom Dialog [ Title: "Estimate before"; Message: MBS( "MongoDB.EstimatedDocumentCount"; $mongo ); Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                        • #insert a record
                                                                                                                                                                        • Set Variable [ $r; Value:MBS( "MongoDB.InsertOne"; $Mongo; test::Insert JSON) ]
                                                                                                                                                                        • Show Custom Dialog [ Title: "Result"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                        • Show Custom Dialog [ Title: "Estimate after insert"; Message: MBS( "MongoDB.EstimatedDocumentCount"; $mongo ); Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                        • Set Variable [ $r; Value:MBS( "MongoDB.AbortTransaction"; $Mongo) ]
                                                                                                                                                                        • Show Custom Dialog [ Title: "Abort"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                        • Show Custom Dialog [ Title: "Estimate after abort"; Message: MBS( "MongoDB.EstimatedDocumentCount"; $mongo ); Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                        • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                                        Fields used in this script
                                                                                                                                                                        Scripts used in this script
                                                                                                                                                                        Layouts used in this script
                                                                                                                                                                          Tables used in this script
                                                                                                                                                                          Table occurrences used by this script
                                                                                                                                                                          Custom Functions used by this script
                                                                                                                                                                            Custom menu set used by this script

                                                                                                                                                                              Previous Script: [Insert with transaction]Next Script: [Run Hello Command]
                                                                                                                                                                              Script NameList Local Sessions
                                                                                                                                                                              Run script with full access privilegesOff
                                                                                                                                                                              Include In MenuYes
                                                                                                                                                                              Layouts that use this script
                                                                                                                                                                                Scripts that use this script
                                                                                                                                                                                  Script Definition
                                                                                                                                                                                  Script Steps
                                                                                                                                                                                  • Perform Script [ “Connect” ]
                                                                                                                                                                                  • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                                                                                                                  • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                                                                                                                  • Exit Script [ ]
                                                                                                                                                                                  • End If
                                                                                                                                                                                  • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                                                                                                                  • If [ MBS("IsError") ]
                                                                                                                                                                                  • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                                                  • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                  • Exit Script [ ]
                                                                                                                                                                                  • End If
                                                                                                                                                                                  • Set Variable [ $r; Value:MBS( "MongoDB.OpenCollection"; $Mongo; test::Collection Name ) ]
                                                                                                                                                                                  • If [ MBS("IsError") ]
                                                                                                                                                                                  • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                                                  • Show Custom Dialog [ Title: "Failed to open collection."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                  • Exit Script [ ]
                                                                                                                                                                                  • End If
                                                                                                                                                                                  • #get cursor for records describing collections
                                                                                                                                                                                  • Set Variable [ $r; Value:MBS( "MongoDB.AggregateDatabase"; $Mongo; "[{\"$listLocalSessions\": {}}]") ]
                                                                                                                                                                                  • If [ MBS("IsError") = 0 ]
                                                                                                                                                                                  • Loop
                                                                                                                                                                                  • Set Variable [ $json; Value:MBS( "MongoDB.CursorNext"; $Mongo) ]
                                                                                                                                                                                  • Exit Loop If [ MBS("IsError") // some error like connection dropped ]
                                                                                                                                                                                  • Exit Loop If [ Length ( $json ) = 0 // end of cursor ]
                                                                                                                                                                                  • Show Custom Dialog [ Title: "Record"; Message: $json; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                                                                                                                                                  • Exit Loop If [ Get(LastMessageChoice) = 2 ]
                                                                                                                                                                                  • End Loop
                                                                                                                                                                                  • End If
                                                                                                                                                                                  • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                                                  Fields used in this script
                                                                                                                                                                                  Scripts used in this script
                                                                                                                                                                                  Layouts used in this script
                                                                                                                                                                                    Tables used in this script
                                                                                                                                                                                    Table occurrences used by this script
                                                                                                                                                                                    Custom Functions used by this script
                                                                                                                                                                                      Custom menu set used by this script

                                                                                                                                                                                        Previous Script: [List Local Sessions]Next Script: [On Window Transaction]
                                                                                                                                                                                        Script NameRun Hello Command
                                                                                                                                                                                        Run script with full access privilegesOff
                                                                                                                                                                                        Include In MenuYes
                                                                                                                                                                                        Layouts that use this script
                                                                                                                                                                                          Scripts that use this script
                                                                                                                                                                                            Script Definition
                                                                                                                                                                                            Script Steps
                                                                                                                                                                                            • Perform Script [ “Connect” ]
                                                                                                                                                                                            • Set Variable [ $Mongo; Value:Get(ScriptResult) ]
                                                                                                                                                                                            • If [ Length ( $Mongo ) = 0 // failed in connect script ]
                                                                                                                                                                                            • Exit Script [ ]
                                                                                                                                                                                            • End If
                                                                                                                                                                                            • Set Variable [ $r; Value:MBS( "MongoDB.OpenDatabase"; $Mongo; test::Database Name ) ]
                                                                                                                                                                                            • If [ MBS("IsError") ]
                                                                                                                                                                                            • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                                                            • Show Custom Dialog [ Title: "Failed to open database."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                            • Exit Script [ ]
                                                                                                                                                                                            • End If
                                                                                                                                                                                            • Set Variable [ $r; Value:MBS( "MongoDB.OpenCollection"; $Mongo; test::Collection Name ) ]
                                                                                                                                                                                            • If [ MBS("IsError") ]
                                                                                                                                                                                            • Set Variable [ $x; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                                                            • Show Custom Dialog [ Title: "Failed to open collection."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                            • Exit Script [ ]
                                                                                                                                                                                            • End If
                                                                                                                                                                                            • #Run Hello command
                                                                                                                                                                                            • Set Variable [ $json; Value:MBS( "MongoDB.Command"; $Mongo; "{ \"hello\": 1 }") ]
                                                                                                                                                                                            • Show Custom Dialog [ Title: "Record"; Message: $json; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                                                                                                                                                            • Set Variable [ $r; Value:MBS( "MongoDB.Release"; $Mongo ) ]
                                                                                                                                                                                            Fields used in this script
                                                                                                                                                                                            Scripts used in this script
                                                                                                                                                                                            Layouts used in this script
                                                                                                                                                                                              Tables used in this script
                                                                                                                                                                                              Table occurrences used by this script
                                                                                                                                                                                              Custom Functions used by this script
                                                                                                                                                                                                Custom menu set used by this script

                                                                                                                                                                                                  Previous Script: [Run Hello Command]
                                                                                                                                                                                                  Script NameOn Window Transaction
                                                                                                                                                                                                  Run script with full access privilegesOff
                                                                                                                                                                                                  Include In MenuNo
                                                                                                                                                                                                  Layouts that use this script
                                                                                                                                                                                                    Scripts that use this script
                                                                                                                                                                                                      Script Definition
                                                                                                                                                                                                      Script Steps
                                                                                                                                                                                                      • #get JSON with changes from script parameter
                                                                                                                                                                                                      • Set Variable [ $json; Value:Get(ScriptParameter) ]
                                                                                                                                                                                                      • #now pass that JSON to MongoDB as a new record
                                                                                                                                                                                                      • Set Variable [ $r; Value:MBS( "MongoDB.InsertOne"; $$MongoDB; $json) ]
                                                                                                                                                                                                      • If [ MBS("IsError") ]
                                                                                                                                                                                                      • Show Custom Dialog [ Title: "Failed to log transaction"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                                      • End If
                                                                                                                                                                                                      Fields used in this script
                                                                                                                                                                                                        Scripts used in this script
                                                                                                                                                                                                          Layouts used in this script
                                                                                                                                                                                                            Tables used in this script
                                                                                                                                                                                                              Table occurrences used by this script
                                                                                                                                                                                                                Custom Functions used by this script
                                                                                                                                                                                                                  Custom menu set used by this script

                                                                                                                                                                                                                    Download example: MongoDB Test

                                                                                                                                                                                                                    Used functions: