}
private BSONObject commandCount(String command, BSONObject query) throws MongoServerException {
String collection = query.get(command).toString();
BSONObject response = new BasicBSONObject();
MongoCollection coll = collections.get(collection);
if (coll == null) {
response.put("missing", Boolean.TRUE);
response.put("n", Integer.valueOf(0));
} else {
response.put("n", Integer.valueOf(coll.count((BSONObject) query.get("query"))));
}
Utils.markOkay(response);
return response;
}