dropIndexes

This commit is contained in:
Scott R. Parish 2010-01-20 06:20:30 -06:00
parent 7df946f697
commit b413958ef7
2 changed files with 10 additions and 3 deletions

View file

@ -48,7 +48,7 @@ module Database.MongoDB
-- * Index -- * Index
Key, Unique, Key, Unique,
Direction(..), Direction(..),
createIndex, dropIndex, createIndex, dropIndex, dropIndexes,
) )
where where
import Control.Exception import Control.Exception
@ -654,6 +654,15 @@ dropIndex c col keys = do
("index", toBson name)] ("index", toBson name)]
return () 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 :: [(Key, Direction)] -> String
indexName = List.concat . List.intersperse "_" . fmap partName indexName = List.concat . List.intersperse "_" . fmap partName
where partName (k, Ascending) = k ++ "_1" where partName (k, Ascending) = k ++ "_1"

2
TODO
View file

@ -45,8 +45,6 @@ MongoDB
* rename * rename
- index operations - index operations
* ensureIndex * ensureIndex
* dropIndex
* dropIndexes
* getIndexInformation * getIndexInformation
- misc operations - misc operations
* explain * explain