-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Binding to EJDB2 C library, an embedded JSON noSQL database -- -- Binding to EJDB2 C library, an embedded JSON noSQL database. Package -- requires libejdb2 to build. Please see the README on GitHub at -- https://github.com/cescobaz/ejdb2haskell#readme @package ejdb2-binding @version 0.3.0.2 module Database.EJDB2.HTTP -- | EJDB HTTP/Websocket Server options. data Options Options :: !Bool -> !Int32 -> Maybe String -> Maybe String -> !Bool -> !Bool -> !Word64 -> Options -- | If HTTP/Websocket endpoint enabled. Default: false [enabled] :: Options -> !Bool -- | Listen port number, required [port] :: Options -> !Int32 -- | Listen IP/host. Default: localhost [bind] :: Options -> Maybe String -- | Server access token passed in X-Access-Token header. Default: -- zero [accessToken] :: Options -> Maybe String -- | Block open thread until http service finished. Otherwise HTTP servee -- started in background. [blocking] :: Options -> !Bool -- | Allow anonymous read-only database access [readAnon] :: Options -> !Bool -- | Maximum WS/HTTP API body size. Default: 64Mb, Min: 512K [maxBodySize] :: Options -> !Word64 -- | Create default Options zero :: Options -- | Storable version of Options data OptionsB options :: OptionsB -> Options -- | Create Storable version of Options build :: Options -> IO OptionsB instance Foreign.Storable.Storable Database.EJDB2.HTTP.OptionsB module Database.EJDB2.IndexMeta -- | Metadata abount collection index. data IndexMeta IndexMeta :: String -> Int64 -> Int64 -> Int64 -> Int64 -> IndexMeta -- | rfc6901 JSON pointer to indexed field [ptr] :: IndexMeta -> String -- | Index mode [mode] :: IndexMeta -> Int64 -- | Index flags [idbf] :: IndexMeta -> Int64 -- | Index database ID [dbid] :: IndexMeta -> Int64 -- | Number records stored in index database [rnum] :: IndexMeta -> Int64 instance GHC.Show.Show Database.EJDB2.IndexMeta.IndexMeta instance GHC.Generics.Generic Database.EJDB2.IndexMeta.IndexMeta instance GHC.Classes.Eq Database.EJDB2.IndexMeta.IndexMeta instance Data.Aeson.Types.FromJSON.FromJSON Database.EJDB2.IndexMeta.IndexMeta module Database.EJDB2.CollectionMeta -- | Metadata about collection. data CollectionMeta CollectionMeta :: String -> Int64 -> Int64 -> [IndexMeta] -> CollectionMeta -- | Collection name [name] :: CollectionMeta -> String -- | Collection database ID [dbid] :: CollectionMeta -> Int64 -- | Number of documents in collection [rnum] :: CollectionMeta -> Int64 -- | List of collections indexes [indexes] :: CollectionMeta -> [IndexMeta] instance GHC.Show.Show Database.EJDB2.CollectionMeta.CollectionMeta instance GHC.Generics.Generic Database.EJDB2.CollectionMeta.CollectionMeta instance GHC.Classes.Eq Database.EJDB2.CollectionMeta.CollectionMeta instance Data.Aeson.Types.FromJSON.FromJSON Database.EJDB2.CollectionMeta.CollectionMeta module Database.EJDB2.Meta -- | Metadata about database. data Meta Meta :: String -> String -> Int64 -> [CollectionMeta] -> Meta -- | EJDB engine version [version] :: Meta -> String -- | Path to storage file [file] :: Meta -> String -- | Storage file size in bytes [size] :: Meta -> Int64 -- | List of collections [collections] :: Meta -> [CollectionMeta] instance GHC.Show.Show Database.EJDB2.Meta.Meta instance GHC.Generics.Generic Database.EJDB2.Meta.Meta instance GHC.Classes.Eq Database.EJDB2.Meta.Meta instance Data.Aeson.Types.FromJSON.FromJSON Database.EJDB2.Meta.Meta module Database.EJDB2.WAL -- | Write ahead log (WAL) options. data Options Options :: !Bool -> !Bool -> !Word32 -> !Word32 -> !Word64 -> !Word8 -> !FunPtr (CBool -> Ptr () -> IO RC) -> !Ptr () -> Options -- | WAL enabled [enabled] :: Options -> !Bool -- | Check CRC32 sum of data blocks during checkpoint. Default: false [checkCRCOnCheckpoint] :: Options -> !Bool -- | Savepoint timeout seconds. Default: 10 sec [savepointTimeoutSec] :: Options -> !Word32 -- | Checkpoint timeout seconds. Default: 300 sec (5 min); [checkpointTimeoutSec] :: Options -> !Word32 -- | WAL file intermediate buffer size. Default: 8Mb [walBufferSz] :: Options -> !Word64 -- | Checkpoint buffer size in bytes. Default: 1Gb [checkpointBufferSz] :: Options -> !Word8 -- | Optional function called before acquiring and after releasing. -- exclusive database lock byAL checkpoint thread. In the case of 'before -- loc first argument will be set to true [walLockInterceptor] :: Options -> !FunPtr (CBool -> Ptr () -> IO RC) -- | Opaque data for walLockInterceptor [walLockInterceptorOpaque] :: Options -> !Ptr () -- | Create default Options zero :: Options instance Foreign.Storable.Storable Database.EJDB2.WAL.Options module Database.EJDB2.KV -- | Database file open modes. data OpenFlags -- | Open storage file in read-only mode. readonlyOpenFlags :: OpenFlags -- | Truncate storage file on open. truncateOpenFlags :: OpenFlags noTrimOnCloseOpenFlags :: OpenFlags -- | IWKV storage open options data Options Options :: Maybe String -> !Word32 -> !Int32 -> ![OpenFlags] -> !Bool -> !Options -> Options -- | Path to database file [path] :: Options -> Maybe String -- | Random seed used for iwu random generator [randomSeed] :: Options -> !Word32 -- | Database storage format version. Leave it as zero for the latest -- supported format. Used only for newly created databases [fmtVersion] :: Options -> !Int32 -- | Database file open modes [oflags] :: Options -> ![OpenFlags] -- | Do not wait and raise error if database is locked by another process [fileLockFailFast] :: Options -> !Bool [wal] :: Options -> !Options -- | Create default Options zero :: Options -- | Storable version of Options data OptionsB -- | Create Storable version of Options build :: Options -> IO OptionsB options :: OptionsB -> Options instance Foreign.Storable.Storable Database.EJDB2.KV.OptionsB module Database.EJDB2.Options -- | EJDB open options data Options Options :: !Options -> !Options -> !Bool -> !Word32 -> !Word32 -> Options -- | IWKV storage options [kv] :: Options -> !Options -- | HTTP/Websocket server options [http] :: Options -> !Options -- | Do not use write-ahead-log. Default: false [noWal] :: Options -> !Bool -- | Max sorting buffer size. If exceeded an overflow temp file for sorted -- data will created. Default 16Mb, min: 1Mb [sortBufferSz] :: Options -> !Word32 -- | Initial size of buffer in bytes used to process/store document during -- query execution. Default 64Kb, min: 16Kb [documentBufferSz] :: Options -> !Word32 -- | Create default Options zero :: Options -- | Storable version of Options data OptionsB options :: OptionsB -> Options -- | Create Storable version of Options build :: Options -> IO OptionsB instance Foreign.Storable.Storable Database.EJDB2.Options.OptionsB module Database.EJDB2 -- | ejdb2 initialization routine. -- -- Must be called before using any of ejdb API function. init :: IO () -- | Reference to database. You can create it by open. data Database -- | Open storage file in read-only mode. readonlyOpenFlags :: OpenFlags -- | Truncate storage file on open. truncateOpenFlags :: OpenFlags noTrimOnCloseOpenFlags :: OpenFlags -- | Create minimal Options for opening a database: just path to -- file and opening mode. minimalOptions :: String -> [OpenFlags] -> Options -- | Open storage file. -- -- Storage can be opened only by one single process at time. -- -- Remember to release database by close when database is no -- longer required. open :: Options -> IO Database -- | Closes storage and frees up all resources. close :: Database -> IO () -- | Retrieve document identified by given id from collection. getById :: FromJSON a => Database -> String -> Int64 -> IO (Maybe a) -- | Executes a given query and returns the number of documents. getCount :: Database -> Query q -> IO Int64 -- | Executes a given query and builds a query result as list of tuple with -- id and document. getList :: FromJSON a => Database -> Query q -> IO [(Int64, Maybe a)] -- | Executes a given query and builds a query result as list of documents -- with id injected as attribute. getList' :: FromJSON a => Database -> Query q -> IO [Maybe a] -- | Save new document into collection under new generated identifier. putNew :: ToJSON a => Database -> String -> a -> IO Int64 -- | Save a given document under specified id. put :: ToJSON a => Database -> String -> a -> Int64 -> IO () -- | Apply JSON merge patch (rfc7396) to the document identified by id or -- insert new document under specified id. -- -- This is an atomic operation. mergeOrPut :: ToJSON a => Database -> String -> a -> Int64 -> IO () -- | Apply rfc6902/rfc7396 JSON patch to the document identified by id. patch :: ToJSON a => Database -> String -> a -> Int64 -> IO () -- | Remove document identified by given id from collection coll. delete :: Database -> String -> Int64 -> IO () -- | Create collection with given name if it has not existed before ensureCollection :: Database -> String -> IO () -- | Remove collection under the given name. removeCollection :: Database -> String -> IO () -- | Rename collection to new name. renameCollection :: Database -> String -> String -> IO () -- | Returns JSON document describing database structure. You can use the -- convenient data Meta getMeta :: FromJSON a => Database -> IO (Maybe a) -- | Index creation mode. data IndexMode -- | Marks index is unique, no duplicated values allowed. uniqueIndexMode :: IndexMode -- | Index values have string type. -- -- Type conversion will be performed on atempt to save value with other -- type. strIndexMode :: IndexMode -- | Index value have floating point type. Internally floating point -- numbers are converted to string with precision of 6 digits after -- decimal point. f64IndexMode :: IndexMode -- | Index values have signed integer 64 bit wide type. -- -- Type conversion will be performed on atempt to save value with other -- type. i64IndexMode :: IndexMode -- | Create index with specified parameters if it has not existed before. -- -- Index path must be fully specified as rfc6901 JSON pointer and must -- not countain unspecified */** element in middle sections. -- --
--   ensureIndex database "mycoll" "/address/street" [uniqueIndexMode | strIndexMode]
--   
ensureIndex :: Database -> String -> String -> [IndexMode] -> IO () -- | Remove index if it has existed before. removeIndex :: Database -> String -> String -> [IndexMode] -> IO () -- | Creates an online database backup image and copies it into the -- specified target file. During online backup phase read/write database -- operations are allowed and not blocked for significant amount of time. -- Backup finish time is placed into result as number of milliseconds -- since epoch. -- -- Online backup guaranties what all records before timestamp will be -- stored in backup image. Later, online backup image can be opened as -- ordinary database file. -- -- In order to avoid deadlocks: close all opened database cursors -- before calling this method or do call in separate thread. onlineBackup :: Database -> String -> IO Word64 -- | Iterate over query result building the result fold :: FromJSON b => Database -> (a -> (Int64, Maybe b) -> a) -> a -> Query q -> IO a -- | Query data with binding. Collection must be specified in query. data Query a Query :: String -> BindM a -> Query a -- | Monad to apply binding to Query type BindM a = StateT BindState IO a -- | Create empty bind noBind :: BindM () -- | Bind bool to query placeholder setBool :: Bool -> String -> BindM () -- | Bind bool to query at specified index setBoolAtIndex :: Bool -> Int -> BindM () -- | Bind number to query placeholder setI64 :: Int64 -> String -> BindM () -- | Bind number to query at specified index setI64AtIndex :: Int64 -> Int -> BindM () -- | Bind Double to query placeholder setF64 :: Double -> String -> BindM () -- | Bind Double to query at specified index setF64AtIndex :: Double -> Int -> BindM () -- | Bind string to query placeholder setString :: String -> String -> BindM () -- | Bind string to query at specified index setStringAtIndex :: String -> Int -> BindM () -- | Bind regex to query placeholder setRegex :: String -> String -> BindM () -- | Bind regex to query at specified index setRegexAtIndex :: String -> Int -> BindM () -- | Bind null value to query placeholder setNull :: String -> BindM () -- | Bind null value to query at specified index setNullAtIndex :: Int -> BindM ()