Other commands work correctly for me, such as:
let commandDictionary = ["count": "trials"]
let error: NSError?
let result = myConnection.runCommandWithDictionary(
commandDictionary,
onDatabaseName: databaseName,
error: &error
)
Attempting a distinct command doesn't, though:
let commandDictionary = ["distinct": "trials", "key": "location"]
let error: NSError?
let result = myConnection.runCommandWithDictionary(
commandDictionary,
onDatabaseName: databaseName,
error: &error
)
After running this, the value of error is: Optional("MONGO_COMMAND_FAILED: The command returned with \'ok\' value of 0"). Running what (I believe) is the same command in the shell gives me sane values:
db.runCommand({distinct: "trials", key: "location"})
Update #1:
Also, MongoConnection.serverVersion() gives me: "2.6.3", and MongoConnection.serverError() returns nil. The verbose server logs show this when running the command in the shell:
2014-12-12T10:11:54.556-0500 [conn69] command eim.$cmd command: distinct { distinct: "trials", key: "metadata.location" } keyUpdates:0 numYields:0 locks(micros) r:606 reslen:210 0ms
And they show this for the command as run by ObjCMongoDb:
2014-12-12T10:10:25.945-0500 [conn171] command eim.$cmd command: isMaster { key: "metadata.location", distinct: "trials" } ntoreturn:1 keyUpdates:0 numYields:0 reslen:138 0ms
Update #2:
It seems that somewhere the distinct command is getting mapped to the isMaster command. This happens for other commands. For instance, the command {listDatabases:1} is mapped to isMaster, as well. However, the command {buildInfo:1} is correctly mapped to buildInfo.