Gun
- Package
- purescript-gun
- Repository
- timdeputter/purescript-gun
The Gun
module provides a basic wrapper for gun.js database.
see https://gun.eco for details about the gun database.
#GunChainCtx Source
data GunChainCtx :: Type
Basic datastructure to chain gun operations like 'put', 'set' or 'once'
#syncWithPeer Source
syncWithPeer :: String -> Effect GunDb
Creates a new gun database instance, and syncs the data with the given peer.
#syncWithPeers Source
syncWithPeers :: Array String -> Effect GunDb
Creates a new gun database instance, and syncs the data with the given peers.
#Getable Source
class Getable a b where
A Typeclass which allows getting data from different sources.
The get
function takes a path either as a String or as an Array of Strings
and returns a GunChainCtx
.
get
can be called on a GunDb
instance or a User
Members
get :: a -> b -> GunChainCtx
Instances
#put Source
put :: forall a. a -> GunChainCtx -> Effect GunChainCtx
Save data into gun, syncing it with your connected peers.
#once Source
once :: forall b a. GunChainCtx -> Aff (Maybe { data :: a, key :: b })
Get the current data without subscribing to updates. Or Nothing
if it cannot be found.
#on Source
on :: forall b a. GunChainCtx -> Aff { data :: a, key :: b }
Subscribe to updates and changes on a node or property in realtime.
#set Source
set :: GunChainCtx -> GunChainCtx -> Effect GunChainCtx
Add a unique item to an unordered list.
#map Source
map :: forall b a. (a -> b) -> GunChainCtx -> GunChainCtx
Map iterates over each property and item on a node, passing it down the chain, transforming the data with the given function. It also subscribes to every item as well and listens for newly inserted items.
#filter Source
filter :: forall a. (a -> Boolean) -> GunChainCtx -> GunChainCtx
Filter iterates over each property and item on a node, passing it down the chain, filtering the data with the given function. It also subscribes to every item as well and listens for newly inserted items.
#each Source
each :: GunChainCtx -> GunChainCtx
Each iterates over each property and item on a node, passing it down the chain. It also subscribes to every item as well and listens for newly inserted items.