Quick Start

Deploy a Database

Using the web console (opens in a new tab), follow the instructions on Deploying a Database

Create a Collection

Using the web console (opens in a new tab), follow the instructions on Creating a Collection

Install WeaveDB

yarn:

yarn add weavedb-sdk

npm:

npm install weavedb-sdk

Initialize WeaveDB

import WeaveDB from "weavedb-sdk"
 
const db = new WeaveDB({ contractTxId: CONTRACT_TX_ID })
await db.init()
💡

Replace CONTRACT_TX_ID with the contractTxId string value returned when deploying your database.

Add a document

const personData = { name: "Bob", age: 20 }
const tx = await db.add(personData, collection_name)
💡

Replace collection_name with the string value name of your collection.

Get a collection

Use get to read a collection:

const result = await db.get(collection_name)

And cget to return the metadata of the documents too:

const result = await db.cget(collection_name)