MongoDBDriver/Collection.cs
/// <summary>
/// Count all items in a collection that match the query spec. 
/// </summary>
/// <remarks>
/// It will return 0 if the collection doesn't exist yet.
/// </remarks>
Count all items in a collection that match the query spec.
Count all items in a collection that match the query spec .
public long Count(Document spec){
            try{
                Document ret = this.Db.SendCommand(new Document().Append("count",this.Name).Append("query",spec));
                double n = (double)ret["n"];
                return Convert.ToInt64(n);
            }catch(MongoCommandException){
                return 0;
            }
        }
public long Count ( Document spec ) { try { Document ret = this . Db . SendCommand ( new Document ( ) . Append ( " " , this . Name ) . Append ( " " , spec ) ) ; double n = ( double ) ret [ " " ] ; return Convert . ToInt64 ( n ) ; } catch ( MongoCommandException ) { return 0 ; } }
Count all items in a collection that match the query spec.
Count all items in a collection that match the query spec .
//Database db = new Database(this.connection, this.dbName); //FIXME This is an exception condition when the namespace is missing.  //-1 might be better here but the console returns 0.
spec
Document
remarks
It will return 0 if the collection doesn't exist yet.
It will return 0 if the collection doesn ' t exist yet .