Skip to content

Writing custom adapters

Thaina Yu edited this page Nov 29, 2020 · 7 revisions

[Background: I/@natevw am writing a new PouchDB adapter called PeerPouch, I'm starting this page as my notes along the way in the hopes it can be made more thorough in the future or at least help someone else get started quicker next time. Please don't consider it authoritative, I don't even know if the customApi is/will-ever-be considered stable…]

Writing a custom PouchDB adapter

Basic shape/registering it

TBD: basic notes on e.g. how to register and how/when adapter gets initialized, e.g https://github.com/natevw/PeerPouch/blob/master/pouch.webrtc.js#L12 and https://github.com/natevw/PeerPouch/blob/master/pouch.webrtc.js#L118

Required "class" methods

[preliminary]

  • destroy
  • valid

Required "instance" methods

[this list is basically copy-pasta grepping for "customApi." in https://github.com/daleharvey/pouchdb/blob/master/packages/pouchdb-core/src/adapter.js right now]

  • bulkDocs
  • _getRevisionTree
  • _doCompaction
  • _get
  • _getAttachment
  • _allDocs
  • _changes
  • _close
  • _info
  • _id
  • _type [optional]