diff --git a/Database/MongoDB.hs b/Database/MongoDB.hs index 7361e8c..72b5cbf 100644 --- a/Database/MongoDB.hs +++ b/Database/MongoDB.hs @@ -48,7 +48,7 @@ module Database.MongoDB -- * Index Key, Unique, Direction(..), - createIndex, dropIndex, + createIndex, dropIndex, dropIndexes, ) where import Control.Exception @@ -654,6 +654,15 @@ dropIndex c col keys = do ("index", toBson name)] return () +-- | Drop all indexes on /FullCollection/. +dropIndexes :: Connection -> FullCollection -> IO () +dropIndexes c col = do + let (db, col') = splitFullCol col + _ <- runCommand c db $ toBsonDoc [("deleteIndexes", toBson col'), + ("index", toBson "*")] + return () + + indexName :: [(Key, Direction)] -> String indexName = List.concat . List.intersperse "_" . fmap partName where partName (k, Ascending) = k ++ "_1" diff --git a/TODO b/TODO index bfca888..c260648 100644 --- a/TODO +++ b/TODO @@ -45,8 +45,6 @@ MongoDB * rename - index operations * ensureIndex - * dropIndex - * dropIndexes * getIndexInformation - misc operations * explain