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
Tables 1
Relationships 0
Layouts 1
Scripts 15
Value Lists 0
Custom Functions 0
Custom Menus 24
File Options
Default custom menu set [Standard FileMaker Menus]
Default theme Apex Blue
When opening file
Minimum allowed version 12.0
Login using Account Name; Account= Admin
Allow user to save password On
Require iOS passcode Off
Show Sign-in fields Off
Switch to layout Off
Hide all toolbars Off
Script triggers
OnFirstWindowOpen Off
OnLastWindowClose Off
OnWindowOpen Off
OnWindowClose Off
OnFileAVPlayerChange Off
OnWindowTransaction Off
Thumbnail Settings
Generate Thumbnails On; Temporary

 

Tables

Table Name
Statistics
Comments
Occurrences in Relationship Graph
test
9 fields defined, 2 records
test

Fields

Table Name: test - 9 Fields
Field Name Type Options Comments On Layouts In Relationships In Scripts In Value Lists
PrimaryKey Normal, Text Auto-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
          CreationTimestamp Normal, Timestamp Auto-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
                  CreatedBy Normal, Text Auto-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
                          ModificationTimestamp Normal, Timestamp Auto-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
                                  ModifiedBy Normal, Text Auto-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 URL Normal, Text Auto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1
                                          • Indexing: None
                                          • Automatically create indexes as needed
                                          • Index Language: English
                                              Database Name Normal, Text Auto-Enter:
                                              • Allow editing
                                              Validation:
                                              • Only during data entry
                                              Storage:
                                              • Repetitions: 1
                                              • Indexing: None
                                              • Automatically create indexes as needed
                                              • Index Language: English
                                                  Collection Name Normal, Text Auto-Enter:
                                                  • Allow editing
                                                  Validation:
                                                  • Only during data entry
                                                  Storage:
                                                  • Repetitions: 1
                                                  • Indexing: None
                                                  • Automatically create indexes as needed
                                                  • Index Language: English
                                                      Insert JSON Normal, Text Auto-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 Properties Coordinates Field Format Field Behavior Quick Find
                                                          • Top: 114 pt
                                                          • Left: 138 pt
                                                          • Bottom: 240 pt
                                                          • Right: 586 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 Properties Coordinates Field Format Field Behavior Quick Find
                                                          • Top: 246 pt
                                                          • Left: 138 pt
                                                          • Bottom: 278 pt
                                                          • Right: 586 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 Properties Coordinates Field Format Field Behavior Quick Find
                                                          • Top: 282 pt
                                                          • Left: 138 pt
                                                          • Bottom: 314 pt
                                                          • Right: 586 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 Properties Coordinates Field Format Field Behavior Quick Find
                                                          • Top: 319 pt
                                                          • Left: 138 pt
                                                          • Bottom: 497 pt
                                                          • Right: 586 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 Properties Coordinates Script/Script Step
                                                            Type:
                                                          • Text: Show Databases
                                                          • Top: 114 pt
                                                          • Left: 691 pt
                                                          • Bottom: 150 pt
                                                          • Right: 915 pt
                                                          • Anchoring: Left, Top
                                                          Perform Script [ “Query database names” ]

                                                          Scripts:


                                                          Button Properties Coordinates Script/Script Step
                                                            Type:
                                                          • Text: Show Collections
                                                          • Top: 159 pt
                                                          • Left: 691 pt
                                                          • Bottom: 195 pt
                                                          • Right: 915 pt
                                                          • Anchoring: Left, Top
                                                          Perform Script [ “Query collection names” ]

                                                          Scripts:


                                                          Button Properties Coordinates Script/Script Step
                                                            Type:
                                                          • Text: Insert Record
                                                          • Top: 294 pt
                                                          • Left: 691 pt
                                                          • Bottom: 330 pt
                                                          • Right: 915 pt
                                                          • Anchoring: Left, Top
                                                          Perform Script [ “Insert” ]

                                                          Scripts:


                                                          Button Properties Coordinates Script/Script Step
                                                            Type:
                                                          • Text: Show Collection Records
                                                          • Top: 204 pt
                                                          • Left: 691 pt
                                                          • Bottom: 240 pt
                                                          • Right: 915 pt
                                                          • Anchoring: Left, Top
                                                          Perform Script [ “Find Collections” ]

                                                          Scripts:


                                                          Button Properties Coordinates Script/Script Step
                                                            Type:
                                                          • Text: Show Database Records
                                                          • Top: 246 pt
                                                          • Left: 691 pt
                                                          • Bottom: 282 pt
                                                          • Right: 915 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 Name Connect
                                                          Run script with full access privileges Off
                                                          Siri Shortcut Visible Off
                                                          Include In Menu Yes
                                                          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
                                                            • #We remove ¶ from the URL, so we can format URLs multi lines
                                                            • Set Variable [ $url; Value:test::MongoDB URL ]
                                                            • Set Variable [ $url; Value:Substitute ( $url; ¶; "") ]
                                                            • Set Variable [ $r; Value:MBS( "MongoDB.SetURI"; $Mongo; $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 Name Query database names
                                                                    Run script with full access privileges Off
                                                                    Siri Shortcut Visible Off
                                                                    Include In Menu Yes
                                                                    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 Name Query collection names
                                                                                  Run script with full access privileges Off
                                                                                  Siri Shortcut Visible Off
                                                                                  Include In Menu Yes
                                                                                  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 Name Find Collections
                                                                                          Run script with full access privileges Off
                                                                                          Siri Shortcut Visible Off
                                                                                          Include In Menu Yes
                                                                                          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 [ Flush: Always ]
                                                                                            • 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 Name Find Databases
                                                                                                  Run script with full access privileges Off
                                                                                                  Siri Shortcut Visible Off
                                                                                                  Include In Menu Yes
                                                                                                  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 [ Flush: Always ]
                                                                                                    • 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 Name Find
                                                                                                          Run script with full access privileges Off
                                                                                                          Siri Shortcut Visible Off
                                                                                                          Include In Menu Yes
                                                                                                          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 [ Flush: Always ]
                                                                                                              • 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 Name Insert
                                                                                                                    Run script with full access privileges Off
                                                                                                                    Siri Shortcut Visible Off
                                                                                                                    Include In Menu Yes
                                                                                                                    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 Name Update one
                                                                                                                            Run script with full access privileges Off
                                                                                                                            Siri Shortcut Visible Off
                                                                                                                            Include In Menu Yes
                                                                                                                            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 Name Update many
                                                                                                                                      Run script with full access privileges Off
                                                                                                                                      Siri Shortcut Visible Off
                                                                                                                                      Include In Menu Yes
                                                                                                                                      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 Name Replace one
                                                                                                                                                Run script with full access privileges Off
                                                                                                                                                Siri Shortcut Visible Off
                                                                                                                                                Include In Menu Yes
                                                                                                                                                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 Name List Keys in Collection
                                                                                                                                                          Run script with full access privileges Off
                                                                                                                                                          Siri Shortcut Visible Off
                                                                                                                                                          Include In Menu Yes
                                                                                                                                                          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 Name Insert with transaction
                                                                                                                                                                    Run script with full access privileges Off
                                                                                                                                                                    Siri Shortcut Visible Off
                                                                                                                                                                    Include In Menu Yes
                                                                                                                                                                    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 Name List Local Sessions
                                                                                                                                                                              Run script with full access privileges Off
                                                                                                                                                                              Siri Shortcut Visible Off
                                                                                                                                                                              Include In Menu Yes
                                                                                                                                                                              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 [ Flush: Always ]
                                                                                                                                                                                  • 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 Name Run Hello Command
                                                                                                                                                                                        Run script with full access privileges Off
                                                                                                                                                                                        Siri Shortcut Visible Off
                                                                                                                                                                                        Include In Menu Yes
                                                                                                                                                                                        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 Name On Window Transaction
                                                                                                                                                                                                  Run script with full access privileges Off
                                                                                                                                                                                                  Siri Shortcut Visible Off
                                                                                                                                                                                                  Include In Menu No
                                                                                                                                                                                                  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: