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

MongoDB.AggregateDatabase

Creates an aggregate database.

Component Version macOS Windows Linux Server iOS SDK
MongoDB 13.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "MongoDB.AggregateDatabase"; MongoDBRef; Pipeline { ; Options } )   More

Parameters

Parameter Description Example Flags
MongoDBRef The reference number for the mongo connection. $MongoDB
Pipeline The pipeline as JSON. "[{\"$listLocalSessions\": {}}]"
Options JSON with options. Optional

Result

Returns OK or error.

Description

Creates an aggregate database.
This function creates a cursor which sends the aggregate command on the underlying database upon the first call to MongoDB.CursorNext. For more information on building aggregation pipelines, see the MongoDB Manual entry on the aggregate command. Note that the pipeline must start with a compatible stage that does not require an underlying collection (e.g. “$currentOp”, “$listLocalSessions”).
Sets the current cursor.
Please review the documentation for MongoDB on how to build the JSON for pipeline or options.

Examples

List local sessions:

Set Variable [ $r ; Value: MBS( "MongoDB.AggregateDatabase"; $Mongo; "[{\"$listLocalSessions\": {}}]") ]
If [ MBS("IsError") = 0 ]
    Loop
        Set Variable [ $json ; Value: MBS( "MongoDB.CursorNext"; $Mongo) ]
        Exit Loop If [ MBS("IsError") // some error like connection dropped ]
        Exit Loop If [ Length ( $json ) = 0 // end of cursor ]
        Show Custom Dialog [ "Record" ; $json ]
        Exit Loop If [ Get(LastMessageChoice) = 2 ]
    End Loop
End If

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

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


MongoDB.AggregateCollection - MongoDB.BSONtoJSON