Permalink
Browse files

GridFS delete/1 and delete/2 functions implemented.

  • Loading branch information...
hammingweight committed Apr 7, 2012
1 parent 8d3ef3c commit 92a69c6bf742b80d719495d76e49a5541e80cf48
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/mongo_gridfs.erl
View
@@ -1,13 +1,16 @@
%@doc GridFS functions.
-module(mongo_gridfs).
--export([delete/2]).
+-export([delete/1, delete/2]).
+
+delete(Selector) ->
+ delete(fs, Selector).
delete(Coll, Selector) ->
- FilesColl = list_to_atom(atom_to_list(Coll) ++ ".fs.files"),
- ChunksColl = list_to_atom(atom_to_list(Coll) ++ ".fs.chunks"),
+ FilesColl = list_to_atom(atom_to_list(Coll) ++ ".files"),
+ ChunksColl = list_to_atom(atom_to_list(Coll) ++ ".chunks"),
Cursor = mongo:find(FilesColl, Selector, {'_id', 1}),
Files = mongo_cursor:rest(Cursor),
Ids = [Id || {'_id', Id} <- Files],
- mongo:delete(ChunksColl, {file_id, {'$in', Ids}}),
- mongo:delete(FilesColl, {file_id, {'$in', Ids}}).
+ mongo:delete(ChunksColl, {files_id, {'$in', Ids}}),
+ mongo:delete(FilesColl, {'_id', {'$in', Ids}}).

0 comments on commit 92a69c6

Please sign in to comment.