Spacetime Client (Browser/Node)
A client to connect to the Spacetime decentralized database.
Install Spacetime
npm install @spacetimexyz/spacetime
yarn add @spacetimexyz/spacetime
Initialize the SDK
import Spacetime from '@spacetimexyz/spacetime'
const db = new Spacetime({
...config
})
Get a single record
You can read data once, by calling the .doc(id: string).get()
method on a collection.
const colRef = db.collection("org/places")
const record = await colRef.doc("id").get()
const { id, ...data } = record
Write data
const colRef = db.collection("org/places")
const doc = await colRef.doc("london").set({
name: "London",
country: "UK",
})
Tests
To run E2E tests, ensure that Spacetime is running, and then run:
yarn test:e2e