Copyright | (c) 2012-2021 Amy de Buitléir |
---|---|
License | BSD-style |
Maintainer | amy@nualeargais.ie |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Database interface for the Créatúr framework.
Synopsis
- class Database d where
- type DBRecord d
- keys :: StateT d IO [String]
- numRecords :: StateT d IO Int
- archivedKeys :: StateT d IO [String]
- lookup :: Serialize (DBRecord d) => String -> StateT d IO (Either String (DBRecord d))
- lookupInArchive :: Serialize (DBRecord d) => String -> StateT d IO (Either String (DBRecord d))
- readAll :: Serialize (DBRecord d) => StateT d IO [Either String (DBRecord d)]
- readAllInArchive :: Serialize (DBRecord d) => StateT d IO [Either String (DBRecord d)]
- store :: (Record (DBRecord d), Serialize (DBRecord d)) => DBRecord d -> StateT d IO ()
- delete :: Serialize (DBRecord d) => String -> StateT d IO ()
- class Record r where
- class Record r => SizedRecord r where
Documentation
class Database d where Source #
A database offering storage and retrieval for records.
keys :: StateT d IO [String] Source #
Get a list of all active keys in the database.
numRecords :: StateT d IO Int Source #
Return the number of records stored in the database.
archivedKeys :: StateT d IO [String] Source #
Get a list of all archived keys in the database. If the database does not implement archiving, it may return an empty list.
lookup :: Serialize (DBRecord d) => String -> StateT d IO (Either String (DBRecord d)) Source #
Read an active record from the database.
lookupInArchive :: Serialize (DBRecord d) => String -> StateT d IO (Either String (DBRecord d)) Source #
Read an archived record from the database.
readAll :: Serialize (DBRecord d) => StateT d IO [Either String (DBRecord d)] Source #
Fetch all active records from the database.
readAllInArchive :: Serialize (DBRecord d) => StateT d IO [Either String (DBRecord d)] Source #
Read all archived records from the database.
store :: (Record (DBRecord d), Serialize (DBRecord d)) => DBRecord d -> StateT d IO () Source #
Write a record to the database. If an agent with the same name already exists, it will be overwritten.
delete :: Serialize (DBRecord d) => String -> StateT d IO () Source #
Remove a record from the database. The database may archive records rather than simply deleting them.