spk-graph-client

1.0.2 • Public • Published

SPK Graph Client

The javascript/typescript client for interacting with documents on SPK network.

Usage

Initialize the client

const spkClient = new SpkClient(SPK_INDEXER_HOST, ceramicClient), 

Create a new document

const docContent = { key: "value" }
const parentId = "optionalParentStreamId"
const created = await spkClient.createDocument(docContent, parentId)
console.log(`Created new document with streamId ${created.streamId} and parent id ${parentId}`)

Fetch a document

const fetched = await spkClient.fetchDocument(streamId)

Update a document

const newContent = { key: "value2" }
await spkClient.updateDocument(streamId, newContent)

Get documents belong to a user

const userDocs = await spkClient.getDocumentsForUser("[Owning User DID]")

Get child documents of a parent

const childDocs = await spkClient.getDocumentChildren("[Parent document stream ID]")

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    1
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i spk-graph-client

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

79 kB

Total Files

30

Last publish

Collaborators

  • vaultec81