Flumedb: Modular Stream-Based Database

2.1.8 · active · verified Wed Apr 22

Flumedb is a modular database system built around an append-only log and streaming views. It acts as an orchestrator, connecting a single `flumelog-*` module (the durable primary data store) with zero or more `flumeview-*` modules (which provide flexible, rebuildable indexes and query interfaces). The core innovation is its star-shaped pipeline architecture, where views stream data from the central log and build their own optimized models. Unlike older designs like `level-sublevel`, `flumedb` views can be easily updated or added; they simply rebuild from the main log if their version changes. This current stable version is 2.1.8. The project does not explicitly state a release cadence, but its components are actively maintained within the `flumedb` GitHub organization. Key differentiators include its robust view rebuilding mechanism, asynchronous views that automatically synchronize upon read, and the ability for views to optimize for queries rather than durability, as they can always regenerate from the canonical log.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize FlumeDB with an in-memory log, attach a reducing view, and then append data and query the view.

var MemLog = require('flumelog-memory') // In-memory log for simple testing
var Reduce = require('flumeview-reduce') // A view that aggregates data
var Flume = require('flumedb')

// Initialize FlumeDB with an in-memory log
var db = Flume(MemLog())
  // Attach a 'sum' view using flumeview-reduce
  .use(
    'sum',
    Reduce(1, function (acc, item) {
      // This reduce function sums the 'foo' property of appended items
      return (acc || 0) + item.foo
    })
  )

// Append some data to the log
db.append({ foo: 1 }, function (err, seq) {
  if (err) throw err
  console.log('Appended item with sequence:', seq)
  
  // Get the current sum from the 'sum' view
  db.sum.get(function (err, value) {
    if (err) throw err
    console.log('Current sum from view:', value) // Expected output: 1
  })
})

db.append({ foo: 5 }, function (err, seq) {
  if (err) throw err
  console.log('Appended another item with sequence:', seq)

  db.sum.get(function (err, value) {
    if (err) throw err
    console.log('Current sum after second append:', value) // Expected output: 6
  })
})

view raw JSON →