mergeless-persistent-0.0.0.0: Support for using mergeless from persistent-based databases

Safe HaskellNone
LanguageHaskell2010

Data.Mergeless.Persistent

Contents

Synopsis

Client side

clientMakeSyncRequestQuery Source #

Arguments

:: (Ord sid, PersistEntity clientRecord, PersistField sid, PersistEntityBackend clientRecord ~ SqlBackend, MonadIO m) 
=> (clientRecord -> a)

How to read a record

-> EntityField clientRecord (Maybe sid)

The server id field

-> EntityField clientRecord Bool

The deleted field

-> SqlPersistT m (SyncRequest (Key clientRecord) sid a) 

Make a sync request on the client side

clientMergeSyncResponseQuery Source #

Arguments

:: (PersistEntity clientRecord, PersistField sid, PersistEntityBackend clientRecord ~ SqlBackend, MonadIO m) 
=> (sid -> a -> clientRecord)

Create an un-deleted synced record on the client side

-> EntityField clientRecord (Maybe sid)

The server id field

-> EntityField clientRecord Bool

The deleted field

-> SyncResponse (Key clientRecord) sid a 
-> SqlPersistT m () 

Merge a sync response on the client side

Raw processors

clientSyncProcessor Source #

Arguments

:: (PersistEntity clientRecord, PersistField sid, PersistEntityBackend clientRecord ~ SqlBackend, MonadIO m) 
=> (sid -> a -> clientRecord)

Create an un-deleted synced record on the client side

-> EntityField clientRecord (Maybe sid)

The server id field

-> EntityField clientRecord Bool

The deleted field

-> ClientSyncProcessor (Key clientRecord) sid a (SqlPersistT m) 

Server side

serverProcessSyncQuery Source #

Arguments

:: (PersistEntity record, PersistEntityBackend record ~ SqlBackend, MonadIO m) 
=> [Filter record]

Filters to select the relevant items

Use these if you have multiple users and you want to sync per-user

-> (record -> a)

How to read a record

-> (a -> record)

How to insert a _new_ record

-> SyncRequest ci (Key record) a 
-> SqlPersistT m (SyncResponse ci (Key record) a) 

Process a sync query on the server side.

serverProcessSyncWithCustomIdQuery Source #

Arguments

:: (Ord sid, PersistEntity record, PersistField sid, PersistEntityBackend record ~ SqlBackend, MonadIO m) 
=> SqlPersistT m sid

The action to generate new identifiers

-> EntityField record sid

The id field

-> [Filter record]

Filters to select the relevant items

Use these if you have multiple users and you want to sync per-user

-> (record -> (sid, a))

How to read a record

-> (sid -> a -> record)

How to insert a _new_ record

-> SyncRequest ci sid a 
-> SqlPersistT m (SyncResponse ci sid a) 

Process a sync query on the server side with a custom id.

Sync processors

serverSyncProcessor Source #

Arguments

:: (PersistEntity record, PersistEntityBackend record ~ SqlBackend, MonadIO m) 
=> [Filter record]

Filters to select the relevant items

Use these if you have multiple users and you want to sync per-user

-> (record -> a)

How to read a record

-> (a -> record)

How to insert a _new_ record

-> ServerSyncProcessor ci (Key record) a (SqlPersistT m) 

A server sync processor that uses the sqlkey of the record as the name

serverSyncProcessorWithCustomId Source #

Arguments

:: (Ord sid, PersistEntity record, PersistField sid, PersistEntityBackend record ~ SqlBackend, MonadIO m) 
=> SqlPersistT m sid

The action to generate new identifiers

-> EntityField record sid

The id field

-> [Filter record]

Filters to select the relevant items

Use these if you have multiple users and you want to sync per-user

-> (record -> (sid, a))

How to read a record

-> (sid -> a -> record)

How to insert a _new_ record

-> ServerSyncProcessor ci sid a (SqlPersistT m) 

A server sync processor that uses a custom key as the name

Utils

Client side

setupUnsyncedClientQuery Source #

Arguments

:: (PersistEntity clientRecord, PersistEntityBackend clientRecord ~ SqlBackend, MonadIO m) 
=> (a -> clientRecord)

How to insert a _new_ record

-> [a] 
-> SqlPersistT m () 

Setup an unsynced client store

You shouldn't need this.

setupClientQuery Source #

Arguments

:: (PersistEntity clientRecord, PersistEntityBackend clientRecord ~ SqlBackend, MonadIO m) 
=> (a -> clientRecord)

Create an un-deleted unsynced record on the client side

-> (sid -> a -> clientRecord)

Create an un-deleted synced record on the client side

-> (sid -> clientRecord)

Create an deleted synced record on the client side

-> ClientStore (Key clientRecord) sid a 
-> SqlPersistT m () 

Setup a client store

You shouldn't need this.

clientGetStoreQuery Source #

Arguments

:: (Ord sid, PersistEntity clientRecord, PersistField sid, PersistEntityBackend clientRecord ~ SqlBackend, MonadIO m) 
=> (clientRecord -> a)

How to red a record

-> EntityField clientRecord (Maybe sid)

The server id field

-> EntityField clientRecord Bool

The deleted field

-> SqlPersistT m (ClientStore (Key clientRecord) sid a) 

Get a client store

You shouldn't need this.

Server side side

serverGetStoreQuery Source #

Arguments

:: (PersistEntity record, PersistEntityBackend record ~ SqlBackend, MonadIO m) 
=> (record -> a)

How to read a record

-> SqlPersistT m (ServerStore (Key record) a) 

Get the server store from the database

You shouldn't need this.

setupServerQuery Source #

Arguments

:: (PersistEntity record, PersistEntityBackend record ~ SqlBackend, MonadIO m) 
=> (a -> record)

How to write a record

-> ServerStore (Key record) a 
-> SqlPersistT m () 

Set up a server store in the database.

You shouldn't need this. This uses insertKey function and is therefore unsafe.