Add allowDiskUse option for aggregates
Merge pull request #120 from acondolu/allow-disk-use
This commit is contained in:
commit
952aed5a1f
1 changed files with 17 additions and 5 deletions
|
@ -1338,16 +1338,28 @@ aggregate :: (MonadIO m, MonadFail m) => Collection -> Pipeline -> Action m [Doc
|
|||
aggregate aColl agg = do
|
||||
aggregateCursor aColl agg def >>= rest
|
||||
|
||||
data AggregateConfig = AggregateConfig {}
|
||||
data AggregateConfig = AggregateConfig
|
||||
{ allowDiskUse :: Bool -- ^ Enable writing to temporary files (aggregations have a 100Mb RAM limit)
|
||||
}
|
||||
deriving Show
|
||||
|
||||
instance Default AggregateConfig where
|
||||
def = AggregateConfig {}
|
||||
def = AggregateConfig
|
||||
{ allowDiskUse = False
|
||||
}
|
||||
|
||||
aggregateCommand :: Collection -> Pipeline -> AggregateConfig -> Document
|
||||
aggregateCommand aColl agg AggregateConfig {..} =
|
||||
[ "aggregate" =: aColl
|
||||
, "pipeline" =: agg
|
||||
, "cursor" =: ([] :: Document)
|
||||
, "allowDiskUse" =: allowDiskUse
|
||||
]
|
||||
|
||||
aggregateCursor :: (MonadIO m, MonadFail m) => Collection -> Pipeline -> AggregateConfig -> Action m Cursor
|
||||
-- ^ Runs an aggregate and unpacks the result. See <http://docs.mongodb.org/manual/core/aggregation/> for details.
|
||||
aggregateCursor aColl agg _ = do
|
||||
response <- runCommand ["aggregate" =: aColl, "pipeline" =: agg, "cursor" =: ([] :: Document)]
|
||||
aggregateCursor aColl agg cfg = do
|
||||
response <- runCommand (aggregateCommand aColl agg cfg)
|
||||
getCursorFromResponse aColl response
|
||||
>>= either (liftIO . throwIO . AggregateFailure) return
|
||||
|
||||
|
|
Loading…
Reference in a new issue