
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
orbit-db-tablestore
Advanced tools
An orbit-db datastore that can be indexed and searched without downloading the entire dataset
An indexed and remoted loaded datastore for orbit-db. Indexed fields are searchable and sortable.
An orbit-db datastore that can be indexed and searched without downloading the entire dataset. Allows the creation of SQL-like tables. Access using ipfs-http-client.
The goal is to be able to load and search large datasets quickly in a browser.
Used in orbit-db.
npm install orbit-db
npm install orbit-db-tablestore
npm install ipfs-http-client
First, create an instance of OrbitDB:
const ipfsClient = require('ipfs-http-client')
const OrbitDB = require('orbit-db')
const TableStore = require('orbit-db-tablestore')
const ipfs = ipfsClient({
host: "localhost",
port: 5001,
protocol: 'http'
})
OrbitDB.addDatabaseType(TableStore.type, TableStore)
const orbitdb = await OrbitDB.createInstance(ipfs)
Each table starts with a schema definition. Creating a schema defines the fields and indexes that will be created in the table. Multiple columns can be indexed and searched. Each index is implemented as a B-tree.
The properties of an index are:
To create a table we'll start by creating a JS class that has a static getter named 'constraints'. It should also contain matching properties for every contraint defined.
class Player {
static get constraints() {
return {
id: { primary: true, unique:true, type: 'number' },
name: { unique: false, type: 'string' },
currentTeam: { unique: false, type: 'string' },
battingHand: { unique: false, type: 'string' },
throwingHand: { unique: false, type: 'string' }
}
}
constructor() {
this.id = null
this.name = null
this.currentTeam = null
this.battingHand = null
this.throwingHand = null
}
}
/** Put in an async function **/
let table = await orbitdb.open("testschema", {
create: true,
type: "table"
})
//Create the schema. Only needs to be done when creating the table initially.
await table.createSchema(Player)
let store = await orbitdb.open(ADDRESS_OF_DATASTORE, {
type: "table"
})
await store.load()
await table.put(5, {
id: 5,
name: "Andrew McCutchen",
currentTeam: "PIT",
battingHand: "R",
throwingHand: "R"
await table.put(6, {
id: 6,
name: "Pedro Alvarez",
currentTeam: "BAL",
battingHand: "R",
throwingHand: "R"
})
await table.put(8, {
id: 8,
name: "Jordy Mercer",
currentTeam: "PIT",
battingHand: "L",
throwingHand: "R"
})
await table.put(9, {
id: 9,
name: "Doug Drabek",
currentTeam: "BAL",
battingHand: "L",
throwingHand: "R"
})
let player = await table.get(9)
console.log(player)
//Prints
// {
// id: 9,
// name: "Doug Drabek",
// currentTeam: "BAL",
// battingHand: "L",
// throwingHand: "R",
// someOtherData: "day"
// }
let list = await table.list(0, 10) //offset 0, limit 10
let teamPIT = await table.getByIndex("currentTeam", "PIT", 100, 0) //100 is the limit and 0 is the offset
let teamBAL = await table.getByIndex("currentTeam", "BAL", 100, 0)
let battingR = await table.getByIndex("battingHand", "R", 100, 0)
let battingL = await table.getByIndex("battingHand", "L", 100, 0)
let throwingR = await table.getByIndex("throwingHand", "R", 100, 0)
let count = await table.count()
Your changes are persisted to disk when you call commit(). Before commit() the store will respond with the old data when queried. Multiple calls to "put" can be made inside the same transaction.
Todo: There should be an auto-commit option somewhere.
await table.commit()
FAQs
An orbit-db datastore that can be indexed and searched without downloading the entire dataset
The npm package orbit-db-tablestore receives a total of 11 weekly downloads. As such, orbit-db-tablestore popularity was classified as not popular.
We found that orbit-db-tablestore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.