[SERVER-5284] Add a command to confirm/deny if a specific command is supported in the current version of mongo Created: 11/Mar/12  Updated: 11/Mar/12  Resolved: 11/Mar/12

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Ryan Nitz Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Commands are added/removed from mongo. A nice feature would be the ability to test if a command is supported by the current version of mongo. Currently, if you issue an unsupported command to mongo it fails and then writes something to the log.

E.g.

db.adminCommand({hasCommand:"getLog"})

This would return something like:

{ "getLog" : 1|0, "ok" : 1 }



 Comments   
Comment by Ryan Nitz [ 11/Mar/12 ]

Sure... it can be extracted, but this is additional work for the developer.

E.g.,

    def hasCommand( self, command, hostDef, connection ):
        """ Returns True if this command is contained """
        cmd = command.lower()
 
        if 'availableCmds' in hostDef:
            return cmd in hostDef['availableCmds']
 
        availableCmds = sets.Set()
 
        for field, value in connection.admin.command( 'listCommands' )['commands'].items():
            availableCmds.add( field.lower() )
 
        hostDef['availableCmds'] = availableCmds
 
        return cmd in hostDef['availableCmds']

Comment by Eliot Horowitz (Inactive) [ 11/Mar/12 ]

There already is a listCommands command.

db.adminCommand( "listCommands" )

Generated at Thu Feb 08 03:08:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.