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
Execute one of the following commands in the root directory of your project.
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
/**
* @param {Object} personData - JSON data for the new document
* @param {string} collection_name - The collection where the document will be added
*/
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
const result = await db.get(collection_name)
💡
Replace collection_name
with the string value name of your collection.