From b413958ef78bf0831af5f46525d6d26e81c12b4f Mon Sep 17 00:00:00 2001 From: "Scott R. Parish" Date: Wed, 20 Jan 2010 06:20:30 -0600 Subject: [PATCH] dropIndexes --- Database/MongoDB.hs | 11 ++++++++++- TODO | 2 -- 2 files changed, 10 insertions(+), 3 deletions(-) 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