validateCollection
This commit is contained in:
parent
6569157051
commit
d7f6cfc348
2 changed files with 8 additions and 2 deletions
|
@ -32,7 +32,7 @@ module Database.MongoDB
|
||||||
-- * Database
|
-- * Database
|
||||||
Database, MongoDBCollectionInvalid,
|
Database, MongoDBCollectionInvalid,
|
||||||
ColCreateOpt(..),
|
ColCreateOpt(..),
|
||||||
collectionNames, createCollection, dropCollection,
|
collectionNames, createCollection, dropCollection, validateCollection,
|
||||||
-- * Collection
|
-- * Collection
|
||||||
Collection, FieldSelector, NumToSkip, NumToReturn, Selector,
|
Collection, FieldSelector, NumToSkip, NumToReturn, Selector,
|
||||||
QueryOpt(..),
|
QueryOpt(..),
|
||||||
|
@ -160,6 +160,13 @@ dropCollection c col = do
|
||||||
_ <- dbCmd c db $ toBsonDoc [("drop", toBson col')]
|
_ <- dbCmd c db $ toBsonDoc [("drop", toBson col')]
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
|
validateCollection :: Connection -> Collection -> IO String
|
||||||
|
validateCollection c col = do
|
||||||
|
let db = dbFromCol col
|
||||||
|
col' = colMinusDB col
|
||||||
|
res <- dbCmd c db $ toBsonDoc [("validate", toBson col')]
|
||||||
|
return $ fromBson $ fromJust $ BSON.lookup "result" res
|
||||||
|
|
||||||
dbFromCol :: Collection -> Database
|
dbFromCol :: Collection -> Database
|
||||||
dbFromCol = List.takeWhile (/= '.')
|
dbFromCol = List.takeWhile (/= '.')
|
||||||
|
|
||||||
|
|
1
TODO
1
TODO
|
@ -38,7 +38,6 @@ MongoDB
|
||||||
* getProfilingLevel
|
* getProfilingLevel
|
||||||
* setProfilingLevel
|
* setProfilingLevel
|
||||||
* getProfilingInfo
|
* getProfilingInfo
|
||||||
* validateCollection
|
|
||||||
- collection
|
- collection
|
||||||
* modify
|
* modify
|
||||||
* replace
|
* replace
|
||||||
|
|
Loading…
Reference in a new issue