The __exec expansion directive operates in much the same manner as the __rest directive. The main difference is that instead of consulting a REST endpoint, an operating system command is referenced, which in turn produces the result. Another difference is that the __exec directive could be used to load an entire configuration file. This gives DevOps the ability to automate mongod or mongos startup options.
As with the __rest directive, a number of parameters are associated with the __exec directive, as summarized here:
Parameter | Notes |
__exec | The OS command to be executed. Note that this command could well be a Python script. |
type | Indicates the formatting of the return value. Currently accepted values are either string or yaml. |
trim | Defaults to none. You can otherwise set this value to whitespace, which causes leading and/or trailing whitespace to be removed from the returned value. |
digest | The SHA-256 digest of the result. digest_key... |