Skip to content

Instantly share code, notes, and snippets.

@ccapndave
Created December 3, 2015 12:20
Show Gist options
  • Save ccapndave/3964506e061488bb113d to your computer and use it in GitHub Desktop.
Save ccapndave/3964506e061488bb113d to your computer and use it in GitHub Desktop.
module PouchDB where
import Task exposing (Task)
import Native.PouchDB
type PouchDB = POUCHDB_IMPLEMENTED_IN_JAVASCRIPT
type PouchError
= Error
type alias PouchDoc a =
{ a | pouchId : Maybe String, pouchRev : Maybe String }
type alias PouchAttachment =
{ content_type : String
, data : String
}
makePouchAttachment : String -> String -> PouchAttachment
makePouchAttachment content_type data =
{ content_type = content_type, data = data }
getPouchDB : String -> Task PouchError PouchDB
getPouchDB dbName =
Native.PouchDB.getPouchDB dbName
get : PouchDB -> String -> Task PouchError a
get db pouchId =
Native.PouchDB.get db pouchId
remove : PouchDB -> PouchDoc a -> Task PouchError Bool
remove db doc =
Native.PouchDB.remove db doc
post : PouchDB -> a -> Task PouchError Bool
post db doc =
Native.PouchDB.post db doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment