SSB-DB2 is a new database for secure-scuttlebutt, designed as a replacement for the older `ssb-db`. Currently at version 8.1.0, it offers significant architectural changes aimed at improving performance and flexibility. Key differentiators include using `bipf` for data storage, replacing `flume` with `jitdb` for specialized indexes, supporting browser environments via `ssb-browser-core`, and enabling efficient partial replication. It has expanded capabilities beyond `ssb-db`, featuring deletion and compaction, support for customizable feed and encryption formats (defaulting to `ssb-classic`), and a powerful query language based on composable JavaScript functions. SSB-DB2 operates as a `secret-stack` plugin, registering within the `db` namespace, and is optimized for modern Node.js environments (>=16).
npm install ssb-db2Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up an SSB peer with ssb-db2, publish a message, and then query for 'post' messages using the new query operators.
Review the 'Migrating from ssb-db' and 'Preventing forking feeds' sections in the `ssb-db2` documentation. For writing to the new log, ensure the old log is fully migrated and deleted, potentially using `config.dangerouslyKillFlumeWhenMigrated`.
Upgrade your Node.js environment to version 16 or newer. Use a tool like `nvm` to manage Node.js versions.
Consult the `ssb-db2` documentation on 'Leveldb plugins' to understand which plugins are needed for specific query types (e.g., `ssb-db2/full-mentions`). Integrate these plugins into your `secret-stack` configuration.
When migrating or using both, utilize `ssb-db2/compat` if you need to run both `ssb-db` and `ssb-db2` simultaneously, or ensure you've fully transitioned to `ssb-db2` as the primary database.
Ensure `sbot.use(require('ssb-db2'))` is called on your `secret-stack` instance before `sbot.call(null, config)`.Verify that `secret-stack` is initialized with `caps` and that `ssb-db2` is correctly added as a plugin before attempting to access `sbot.db`.
Convert your imports to ESM syntax (e.g., `import SecretStack from 'secret-stack'`) or ensure your files are treated as CommonJS modules.
Double-check the spelling of the operator. Ensure all query operators are imported specifically from `ssb-db2/operators`, e.g., `const { where, type } = require('ssb-db2/operators')`.