Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- init :: IO ()
- data Database
- readonlyOpenFlags :: OpenFlags
- truncateOpenFlags :: OpenFlags
- noTrimOnCloseOpenFlags :: OpenFlags
- minimalOptions :: String -> [OpenFlags] -> Options
- open :: Options -> IO Database
- close :: Database -> IO ()
- getById :: FromJSON a => Database -> String -> Int64 -> IO (Maybe a)
- getCount :: Database -> Query -> IO Int64
- getList :: FromJSON a => Database -> Query -> IO [(Int64, Maybe a)]
- getList' :: FromJSON a => Database -> Query -> IO [Maybe a]
- putNew :: ToJSON a => Database -> String -> a -> IO Int64
- put :: ToJSON a => Database -> String -> a -> Int64 -> IO ()
- mergeOrPut :: ToJSON a => Database -> String -> a -> Int64 -> IO ()
- patch :: ToJSON a => Database -> String -> a -> Int64 -> IO ()
- delete :: Database -> String -> Int64 -> IO ()
- ensureCollection :: Database -> String -> IO ()
- removeCollection :: Database -> String -> IO ()
- renameCollection :: Database -> String -> String -> IO ()
- getMeta :: FromJSON a => Database -> IO (Maybe a)
- data IndexMode
- uniqueIndexMode :: IndexMode
- strIndexMode :: IndexMode
- f64IndexMode :: IndexMode
- i64IndexMode :: IndexMode
- ensureIndex :: Database -> String -> String -> [IndexMode] -> IO ()
- removeIndex :: Database -> String -> String -> [IndexMode] -> IO ()
- onlineBackup :: Database -> String -> IO Word64
- fold :: FromJSON b => Database -> (a -> (Int64, Maybe b) -> a) -> a -> Query -> IO a
Documentation
ejdb2 initialization routine.
Must be called before using any of ejdb API function.
readonlyOpenFlags :: OpenFlags Source #
Open storage file in read-only mode.
truncateOpenFlags :: OpenFlags Source #
Truncate storage file on open.
Create minimal Options
for opening a database: just path to file and opening mode.
open :: Options -> IO Database Source #
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.
:: FromJSON a | |
=> Database | |
-> String | Collection name |
-> Int64 | Document identifier. Not zero |
-> IO (Maybe a) |
Retrieve document identified by given id from collection.
getCount :: Database -> Query -> IO Int64 Source #
Executes a given query and returns the number of documents.
getList :: FromJSON a => Database -> Query -> IO [(Int64, Maybe a)] Source #
Executes a given query and builds a query result as list of tuple with id and document.
getList' :: FromJSON a => Database -> Query -> IO [Maybe a] Source #
Executes a given query and builds a query result as list of documents with id injected as attribute.
:: ToJSON a | |
=> Database | |
-> String | Collection name |
-> a | Document |
-> IO Int64 | New document identifier. Not zero |
Save new document into collection under new generated identifier.
:: ToJSON a | |
=> Database | |
-> String | Collection name |
-> a | Document |
-> Int64 | Document identifier. Not zero |
-> IO () |
Save a given document under specified id.
:: ToJSON a | |
=> Database | |
-> String | Collection name |
-> a | JSON merge patch conformed to rfc7396 specification |
-> Int64 | Document identifier. Not zero |
-> IO () |
Apply JSON merge patch (rfc7396) to the document identified by id or insert new document under specified id.
This is an atomic operation.
:: ToJSON a | |
=> Database | |
-> String | Collection name |
-> a | JSON patch conformed to rfc6902 or rfc7396 specification |
-> Int64 | Document identifier. Not zero |
-> IO () |
Apply rfc6902/rfc7396 JSON patch to the document identified by id.
Remove document identified by given id from collection coll.
Create collection with given name if it has not existed before
Remove collection under the given name.
Rename collection to new name.
Returns JSON document describing database structure. You can use the convenient data Meta
uniqueIndexMode :: IndexMode Source #
Marks index is unique, no duplicated values allowed.
strIndexMode :: IndexMode Source #
Index values have string type.
Type conversion will be performed on atempt to save value with other type.
f64IndexMode :: IndexMode Source #
Index value have floating point type. Internally floating point numbers are converted to string with precision of 6 digits after decimal point.
i64IndexMode :: IndexMode Source #
Index values have signed integer 64 bit wide type.
Type conversion will be performed on atempt to save value with other type.
:: Database | |
-> String | Collection name |
-> String | rfc6901 JSON pointer to indexed field |
-> [IndexMode] | Index mode |
-> IO () |
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]
:: Database | |
-> String | Collection name |
-> String | rfc6901 JSON pointer to indexed field |
-> [IndexMode] | Index mode |
-> IO () |
Remove index if it has existed before.
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.