title: String Mongo delete all files from GridFs
body: <p>Using Spring Mongo is there a way of deleting multiple files from Mongo(stored with GridFS) all at once using only query or something similar? For example if I have in collection .files a field Language I want to be able to delete all entries from .files and also from .chunks in a single query. Not sure if this is possible in Mongo (outside Spring).</p>
  
  <p>Tried to use GridFsTemplate but the delete method calls GridFS.remove method (code from Spring-Mongodb) </p>
  
  <pre><code>public void delete(Query query) {
      getGridFs().remove(getMappedQuery(query));
  }
  </code></pre>
  
  <p>And this method gets all files in memory and then deletes them one by one:</p>
  
  <pre><code> public void remove( DBObject query ){
      for ( GridFSDBFile f : find( query ) ){
          f.remove();
      }
  }
  void remove(){
      _fs._filesCollection.remove( new BasicDBObject( "_id" , _id ) );
      _fs._chunkCollection.remove( new BasicDBObject( "files_id" , _id ) );
  }
  </code></pre>
  
  <p>UPDATE: from comments:</p>
  
  <blockquote>
    <p>Yes, you can't perform such kind of queries in MongoDB. Also, there is no direct way of deleting bunch of files in GridFS using both mongofiles command line tool and mongo java driver.</p>
  </blockquote>