-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | RocksDB database querying library for Haskell -- -- Please see the README on GitHub at -- https://github.com/jprupp/rocksdb-query#readme @package rocksdb-query @version 0.4.2 -- | Query functions to make interaction with RocksDB stores easier and -- safer. module Database.RocksDB.Query -- | Class for types that are database keys. class Key key -- | Class for types that are corresponding database key and value. class KeyValue key value -- | Read a value from the database, or Nothing if not found. retrieve :: (MonadIO m, KeyValue key value, Serialize key, Serialize value) => DB -> key -> m (Maybe value) retrieveCF :: (MonadIO m, KeyValue key value, Serialize key, Serialize value) => DB -> ColumnFamily -> key -> m (Maybe value) -- | Read a value from the database, or Nothing if not found. retrieveCommon :: (MonadIO m, KeyValue key value, Serialize key, Serialize value) => DB -> Maybe ColumnFamily -> key -> m (Maybe value) matchRecursiveList :: (MonadIO m, KeyValue key value, Serialize key, Serialize value) => key -> Iterator -> m [(key, value)] -- | Internal function for recursively matching a key. matchRecursive :: (MonadIO m, KeyValue key value, Serialize key, Serialize value) => key -> Iterator -> ConduitT i (key, value) m () -- | Pass a short key to filter all the elements whose key prefix match it. -- Use a sum type for keys that allows to create a version of the key -- that serializes to a prefix of a full key. -- --
--   data MyKey = ShortKey String | FullKey String String deriving Show
--   instance Serialize MyKey where
--     put (ShortKey a)  = put a
--     put (FullKey a b) = put a >> put b
--     get = FullKey <$> get <*> get
--   instance KeyValue MyKey String
--   main = do
--     db <- open "test-db" defaultOptions {createIfMissing = True}
--     insert db (FullKey "hello" "world") "despite all my rage"
--     Just record <- runResourceT . runConduit $
--       matching db def (ShortKey "hello") .| headC
--     print (record :: (MyKey, String))
--     -- (Fullkey "hello" "world","despite all my rage")
--   
-- -- In this example the ShortKey is serialized to the prefix of -- the only element in the database, which is then returned. Since the -- get function of the Serialize instance for -- MyKey only understands how to deserialize a FullKey, -- then that is what is returned. matching :: (MonadIO m, KeyValue key value, Serialize key, Serialize value) => Iterator -> key -> ConduitT i (key, value) m () -- | Like matching, but skip to the second key passed as argument, -- or after if there is no entry for the second key. matchingSkip :: (MonadIO m, KeyValue key value, Serialize key, Serialize value) => Iterator -> key -> key -> ConduitT i (key, value) m () -- | Insert a record into the database. insert :: (MonadIO m, KeyValue key value, Serialize key, Serialize value) => DB -> key -> value -> m () -- | Insert a record into the database. insertCF :: (MonadIO m, KeyValue key value, Serialize key, Serialize value) => DB -> ColumnFamily -> key -> value -> m () -- | Delete a record from the database. remove :: (MonadIO m, Key key, Serialize key) => DB -> key -> m () -- | Delete a record from the database. removeCF :: (MonadIO m, Key key, Serialize key) => DB -> ColumnFamily -> key -> m () -- | Get the BatchOp to insert a record in the database. insertOp :: (KeyValue key value, Serialize key, Serialize value) => key -> value -> BatchOp -- | Get the BatchOp to insert a record in the database. insertOpCF :: (KeyValue key value, Serialize key, Serialize value) => ColumnFamily -> key -> value -> BatchOp -- | Get the BatchOp to delete a record from the database. deleteOp :: (Key key, Serialize key) => key -> BatchOp -- | Get the BatchOp to delete a record from the database. deleteOpCF :: (Key key, Serialize key) => ColumnFamily -> key -> BatchOp -- | Write a batch to the database. writeBatch :: MonadIO m => DB -> [BatchOp] -> m () -- | Like matching but return the first element only. firstMatching :: (MonadUnliftIO m, KeyValue key value, Serialize key, Serialize value) => DB -> key -> m (Maybe (key, value)) -- | Like matching but return the first element only. firstMatchingCF :: (MonadUnliftIO m, KeyValue key value, Serialize key, Serialize value) => DB -> ColumnFamily -> key -> m (Maybe (key, value)) -- | Like matchingSkip, but return the first element only. firstMatchingSkip :: (MonadUnliftIO m, KeyValue key value, Serialize key, Serialize value) => DB -> key -> key -> m (Maybe (key, value)) -- | Like matchingSkip, but return the first element only. firstMatchingSkipCF :: (MonadUnliftIO m, KeyValue key value, Serialize key, Serialize value) => DB -> ColumnFamily -> key -> key -> m (Maybe (key, value)) -- | Like matching but return a list. matchingAsList :: (MonadUnliftIO m, KeyValue key value, Serialize key, Serialize value) => DB -> key -> m [(key, value)] -- | Like matching but return a list. matchingAsListCF :: (MonadUnliftIO m, KeyValue key value, Serialize key, Serialize value) => DB -> ColumnFamily -> key -> m [(key, value)] -- | Like matchingSkip, but return a list. matchingSkipAsList :: (MonadUnliftIO m, KeyValue key value, Serialize key, Serialize value) => DB -> key -> key -> m [(key, value)] -- | Like matchingSkip, but return a list. matchingSkipAsListCF :: (MonadUnliftIO m, KeyValue key value, Serialize key, Serialize value) => DB -> ColumnFamily -> key -> key -> m [(key, value)]