Safe Haskell | None |
---|---|
Language | Haskell2010 |
This implements the Key/Value API.
Generally, the data stored knows about its own key using via the
OrchestrateData
class instance defined for it.
- lookup :: FromJSON v => Collection -> Key -> OrchestrateIO (Maybe v)
- listVals :: FromJSON v => Collection -> Maybe Int -> Range Key -> OrchestrateIO (KVList v)
- putV :: OrchestrateData v => v -> IfMatch -> OrchestrateIO Location
- putKV :: OrchestrateData v => Key -> v -> IfMatch -> OrchestrateIO Location
- postV :: OrchestrateData v => v -> OrchestrateIO (Location, Maybe Key)
- deleteV :: OrchestrateData v => v -> IfMatch' -> OrchestrateIO ()
- deleteKV :: OrchestrateData v => Key -> v -> IfMatch' -> OrchestrateIO ()
- purgeV :: OrchestrateData v => v -> IfMatch' -> OrchestrateIO ()
- purgeKV :: OrchestrateData v => Key -> v -> IfMatch' -> OrchestrateIO ()
Accessing Data
lookup :: FromJSON v => Collection -> Key -> OrchestrateIO (Maybe v) Source
This retrieves a value from a collection.
lookup "contacts" "mom"
:: FromJSON v | |
=> Collection | The collection to list data from. |
-> Maybe Int | The maximum number of items to retrieve. |
-> Range Key | The range of keys to query. |
-> OrchestrateIO (KVList v) | Returns a collection of data. |
This lists all the data in the collection within the range given.
listVals "coll-name" Nothing (Open, Open)
Adding and Updating Data
:: OrchestrateData v | |
=> v | The data to store in the database. |
-> IfMatch | If specified, this operation only succeeds if the ref specified matches the currently stored ref for this data. |
-> OrchestrateIO Location | Returns the location of the data. |
This inserts data into the database or updates existing data using
a key generated by the OrchestrateData
instance.
putV data NoMatch
:: OrchestrateData v | |
=> Key | The key to store the data under. |
-> v | The data to store. |
-> IfMatch | If specified, this operation only succeeds if the ref specified matches the currently stored ref for this data. |
-> OrchestrateIO Location | Returns the location of the data. |
This inserts data into the database or updates data in the database.
This overrides the key provided by the data type's OrchestrateData
instance. However, it still requires an implementation of that data type
for the collection name.
putKV "key" data NoMatch
:: OrchestrateData v | |
=> v | The data to store. |
-> OrchestrateIO (Location, Maybe Key) | The |
This inserts data in the database, generating a new database key for it.
postV data
Deleting Data
:: OrchestrateData v | |
=> v | The data to remove. |
-> IfMatch' | If given, this operation only succeeds if the ref specified matches the currently stored ref for this data. |
-> OrchestrateIO () |
This removes data from the database.
deleteV data Nothing
:: OrchestrateData v | |
=> Key | The key the data is stored under. |
-> v | The data to remove. |
-> IfMatch' | If given, this operation only succeeds if the ref specified matches the currently stored ref for this data. |
-> OrchestrateIO () |
This removes data from the database.
deleteKV "key" data Nothing
:: OrchestrateData v | |
=> v | The data to remove. |
-> IfMatch' | If given, this operation only succeeds if the ref specified matches the currently stored ref for this data. |
-> OrchestrateIO () |
This purges data from the database. Purging not only removes the data, but also all history and secondary items for it.
purgeV data Nothing
:: OrchestrateData v | |
=> Key | The key the data is stored under. |
-> v | The data to remove. |
-> IfMatch' | If given, this operation only succeeds if the ref specified matches the currently stored ref for this data. |
-> OrchestrateIO () |
This purges data from the database. Purging not only removes the data, but also all history and secondary items for it.
purgeKV "key" data Nothing