Skip to content

youribot/orbit-db-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

orbit-db-test

docstore is a document database to which documents can be stored and indexed by a specified key. Useful for example building search indices or version controlling documents and data.

Build Status

docstore(name, options)

Package: orbit-db-docstore

const db = orbitdb.docstore('orbit.users.shamb0t.profile')

By default, documents are indexed by field '_id'. You can also specify the field to index by:

const db = orbitdb.docstore('orbit.users.shamb0t.profile', { indexBy: 'name' })
  • put(doc)

    db.put({ _id: 'QmAwesomeIpfsHash', name: 'shamb0t', followers: 500 }).then((hash) => ...)
  • get(key)

    const profile = db.get('shamb0t')
      .map((e) => e.payload.value)
    // [{ _id: 'shamb0t', name: 'shamb0t', followers: 500 }]
  • query(mapper)

    const all = db.query((doc) => doc.followers >= 500)
    // [{ _id: 'shamb0t', name: 'shamb0t', followers: 500 }]
  • del(key)

    db.del('shamb0t').then((removed) => ...)
  • load()

    Load the locally persisted database state to memory.

    db.events.on('ready', () => {
      /* query */
    })
    db.load()
  • events

    db.events.on('ready', () => /* local database loaded in memory */ )
    db.events.on('synced', () => /* query for updated results */ )

About

orbit-db docstore implementation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published