public Collection CreateCollection(String name, Document options) { Document cmd = new Document(); cmd.Append("create", name).Update(options); db.SendCommand(cmd); return(new Collection(name, connection, this.name)); }
public void DropIndex(string name) { Document cmd = new Document(); cmd.Append("deleteIndexes", this.name).Append("index", name); db.SendCommand(cmd); this.refresh(); }
public long Count(Document spec) { Database db = new Database(this.connection, this.dbName); try{ Document ret = db.SendCommand(new Document().Append("count",this.Name).Append("query",spec)); double n = (double)ret["n"]; return Convert.ToInt64(n); }catch(MongoCommandException){ //FIXME This is an exception condition when the namespace is missing. -1 might be better here but the console returns 0. return 0; } }
public MapReduce Execute() { if (cmd.Contains("map") == false || cmd.Contains("reduce") == false) { throw new InvalidOperationException("Cannot execute without a map and reduce function"); } canModify = false; try{ result = new MapReduce.MapReduceResult(db.SendCommand(cmd)); }catch (MongoCommandException mce) { result = new MapReduce.MapReduceResult(mce.Error); throw new MongoMapReduceException(mce, this); } return(this); }