Safe Haskell | Trustworthy |
---|
This module exports several classes and combinators that operated on
Structured
types. Specifically, we provide the structured versions
of mongoDB
''s combinators, including structured query creation.
- insert :: (MonadIO' m, Structured a) => a -> Action m Value
- insert_ :: (MonadIO' m, Structured a) => a -> Action m ()
- insertMany :: (MonadIO' m, Structured a) => [a] -> Action m [Value]
- insertMany_ :: (MonadIO' m, Structured a) => [a] -> Action m ()
- insertAll :: (MonadIO' m, Structured a) => [a] -> Action m [Value]
- insertAll_ :: (MonadIO' m, Structured a) => [a] -> Action m ()
- save :: (MonadIO' m, Structured a) => a -> Action m ()
- delete :: MonadIO m => StructuredSelection -> Action m ()
- deleteOne :: MonadIO m => StructuredSelection -> Action m ()
- asc :: Selectable a f t => f -> OrderExp
- desc :: Selectable a f t => f -> OrderExp
- data StructuredQuery
- limit :: StructuredQuery -> Word32
- skip :: StructuredQuery -> Word32
- sort :: StructuredQuery -> [OrderExp]
- find :: (Functor m, MonadIO m, MonadBaseControl IO m) => StructuredQuery -> Action m StructuredCursor
- findOne :: (MonadIO m, Structured a) => StructuredQuery -> Action m (Maybe a)
- fetch :: (MonadIO m, Functor m, Structured a) => StructuredQuery -> Action m (Maybe a)
- count :: MonadIO' m => StructuredQuery -> Action m Int
- data StructuredSelection
- class StructuredSelect aQorS where
- select :: Structured a => QueryExp a -> aQorS
- class Val t => Selectable a f t | f -> a, f -> t where
- (.!) :: (Selectable r f t, Selectable t f' t') => f -> f' -> Nested f f'
- data QueryExp a
- (.*) :: Structured a => QueryExp a
- (.==) :: (Val t, Selectable a f t) => f -> t -> QueryExp a
- (./=) :: (Val t, Selectable a f t) => f -> t -> QueryExp a
- (.<) :: (Val t, Selectable a f t) => f -> t -> QueryExp a
- (.<=) :: (Val t, Selectable a f t) => f -> t -> QueryExp a
- (.>) :: (Val t, Selectable a f t) => f -> t -> QueryExp a
- (.>=) :: (Val t, Selectable a f t) => f -> t -> QueryExp a
- (.&&) :: QueryExp a -> QueryExp a -> QueryExp a
- (.||) :: QueryExp a -> QueryExp a -> QueryExp a
- not_ :: QueryExp a -> QueryExp a
- data StructuredCursor
- closeCursor :: (MonadIO m, MonadBaseControl IO m) => StructuredCursor -> Action m ()
- isCursorClosed :: (MonadIO m, MonadBase IO m) => StructuredCursor -> Action m Bool
- nextBatch :: (Structured a, Functor m, MonadIO m, MonadBaseControl IO m) => StructuredCursor -> Action m [Maybe a]
- next :: (Structured a, MonadIO m, MonadBaseControl IO m) => StructuredCursor -> Action m (Either () (Maybe a))
- nextN :: (Structured a, Functor m, MonadIO m, MonadBaseControl IO m) => Int -> StructuredCursor -> Action m [Maybe a]
- rest :: (Structured a, Functor m, MonadIO m, MonadBaseControl IO m) => StructuredCursor -> Action m [Maybe a]
- module Database.MongoDB.Query
- data Value
Insert
insert :: (MonadIO' m, Structured a) => a -> Action m ValueSource
Inserts document to its corresponding collection and return the "_id" value.
insert_ :: (MonadIO' m, Structured a) => a -> Action m ()Source
Same as insert
but discarding result.
insertMany :: (MonadIO' m, Structured a) => [a] -> Action m [Value]Source
Inserts documents to their corresponding collection and return their "_id" values.
insertMany_ :: (MonadIO' m, Structured a) => [a] -> Action m ()Source
Same as insertMany
but discarding result.
insertAll :: (MonadIO' m, Structured a) => [a] -> Action m [Value]Source
Inserts documents to their corresponding collection and return
their "_id" values. Unlike insertMany
, this function keeps
inserting remaining documents even if an error occurs.
insertAll_ :: (MonadIO' m, Structured a) => [a] -> Action m ()Source
Same as insertAll
but discarding result.
Update
save :: (MonadIO' m, Structured a) => a -> Action m ()Source
Save document to collection. If the SObjId
field is set then
the document is updated, otherwise we perform an insert.
Delete
delete :: MonadIO m => StructuredSelection -> Action m ()Source
Delete all documents that match the selection/query.
deleteOne :: MonadIO m => StructuredSelection -> Action m ()Source
Delete the first documents that match the selection/query.
Order
asc :: Selectable a f t => f -> OrderExpSource
Sort by field, ascending
desc :: Selectable a f t => f -> OrderExpSource
Sort by field, descending
Query
data StructuredQuery Source
Wrapper for mongoDB
's Query
type.
limit :: StructuredQuery -> Word32Source
Maximum number of objects to return (default: 0, no limit).
skip :: StructuredQuery -> Word32Source
Number of matching objects to skip (default: 0).
sort :: StructuredQuery -> [OrderExp]Source
Sortresult by this order.
find :: (Functor m, MonadIO m, MonadBaseControl IO m) => StructuredQuery -> Action m StructuredCursorSource
Find documents satisfying query
findOne :: (MonadIO m, Structured a) => StructuredQuery -> Action m (Maybe a)Source
Find documents satisfying query
fetch :: (MonadIO m, Functor m, Structured a) => StructuredQuery -> Action m (Maybe a)Source
Same as findOne
but throws DocNotFound
if none match.
count :: MonadIO' m => StructuredQuery -> Action m IntSource
Count number of documents satisfying query.
Structured selections/queries
data StructuredSelection Source
Wrapper for mongoDB
's Selection
type.
class StructuredSelect aQorS whereSource
Analog to mongoDB
's Select
class
select :: Structured a => QueryExp a -> aQorSSource
Create a selection or query from an expression
class Val t => Selectable a f t | f -> a, f -> t whereSource
Class defining a selectable type. Type a
corresponds to the
record type, f
corresponds to the field or facet, and t
corresponds to the field/facet type.
(Selectable r f t, Selectable t f' t') => Selectable r (Nested f f') t' |
(.!) :: (Selectable r f t, Selectable t f' t') => f -> f' -> Nested f f'Source
Combining two field names to create a Nested
type.
(.*) :: Structured a => QueryExp aSource
Combinator for ==
(.==) :: (Val t, Selectable a f t) => f -> t -> QueryExp aSource
Combinator for ==
(./=) :: (Val t, Selectable a f t) => f -> t -> QueryExp aSource
Combinator for $ne
(.<) :: (Val t, Selectable a f t) => f -> t -> QueryExp aSource
Combinator for <
(.<=) :: (Val t, Selectable a f t) => f -> t -> QueryExp aSource
Combinator for <=
(.>) :: (Val t, Selectable a f t) => f -> t -> QueryExp aSource
Combinator for >
(.>=) :: (Val t, Selectable a f t) => f -> t -> QueryExp aSource
Combinator for >=
Cursor
data StructuredCursor Source
Wrapper for mongoDB
's Cursor
.
closeCursor :: (MonadIO m, MonadBaseControl IO m) => StructuredCursor -> Action m ()Source
Close the cursor.
isCursorClosed :: (MonadIO m, MonadBase IO m) => StructuredCursor -> Action m BoolSource
Check if the cursor is closed.
nextBatch :: (Structured a, Functor m, MonadIO m, MonadBaseControl IO m) => StructuredCursor -> Action m [Maybe a]Source
Return next batch of structured documents.
next :: (Structured a, MonadIO m, MonadBaseControl IO m) => StructuredCursor -> Action m (Either () (Maybe a))Source
nextN :: (Structured a, Functor m, MonadIO m, MonadBaseControl IO m) => Int -> StructuredCursor -> Action m [Maybe a]Source
Return up to next N
documents.
rest :: (Structured a, Functor m, MonadIO m, MonadBaseControl IO m) => StructuredCursor -> Action m [Maybe a]Source
Return the remaining documents in query result.
Rexports
module Database.MongoDB.Query