How to avoid the output part starting from "Ok:1"

Hi Team,

I want to avoid bottom part of the output in MongoDB.

For ex:

MongoDB Enterprise replica001:PRIMARY> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
{
        "featureCompatibilityVersion" : {
                "version" : "4.0"
        },
        "ok" : 1,
        "operationTime" : Timestamp(1609422524, 1),
        "$clusterTime" : {
                "clusterTime" : Timestamp(1609422524, 1),
                "signature" : {
                        "hash" : BinData(0,"00U9i7OroDkKT0fyn18KvNX7dM8="),
                        "keyId" : NumberLong("6895568894216372225")
                }
        }
}

In the above output, I want to avoid the output part starting from “ok:1”
How can i do that…

I want an output similar to the following:

{
        "featureCompatibilityVersion" : {
                "version" : "4.0"
        }
}

Please suggest me how I can achieve this.

Thanks in advance

Note that the output is an object so you can access any member.

The following will not be exactly like you want but very close.

> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ).featureCompatibilityVersion
{ "version" : "4.0" }
2 Likes

Hi steevej,

Cool Stuff :slight_smile:
Thank you…

Happy New Year!!!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.