dropIndex
This commit is contained in:
parent
f1aa28b9e4
commit
7df946f697
1 changed files with 10 additions and 1 deletions
|
@ -48,7 +48,7 @@ module Database.MongoDB
|
|||
-- * Index
|
||||
Key, Unique,
|
||||
Direction(..),
|
||||
createIndex,
|
||||
createIndex, dropIndex,
|
||||
)
|
||||
where
|
||||
import Control.Exception
|
||||
|
@ -645,6 +645,15 @@ createIndex c col keys uniq = do
|
|||
("unique", toBson uniq)]
|
||||
return name
|
||||
|
||||
-- | Drop the specified index on the given /FullCollection/.
|
||||
dropIndex :: Connection -> FullCollection -> [(Key, Direction)] -> IO ()
|
||||
dropIndex c col keys = do
|
||||
let (db, col') = splitFullCol col
|
||||
name = indexName keys
|
||||
_ <- runCommand c db $ toBsonDoc [("deleteIndexes", toBson col'),
|
||||
("index", toBson name)]
|
||||
return ()
|
||||
|
||||
indexName :: [(Key, Direction)] -> String
|
||||
indexName = List.concat . List.intersperse "_" . fmap partName
|
||||
where partName (k, Ascending) = k ++ "_1"
|
||||
|
|
Loading…
Reference in a new issue