{"id":18499,"library":"livedb","title":"livedb","description":"Database wrapper for realtime applications, providing the backend for ShareJS, Racer, and Derby. This package (v0.5.13 at current release) exposes an API for submitting operations (via OT), subscribing to document changes, and making live queries. It requires a separate database backend (e.g., livedb-mongo for MongoDB) and an optional driver for multi-server setups. Key differentiators: built for Operational Transformation, stores all operations forever, and supports live query result feeds. Note: the v5 releases listed are for the related share/sharedb package, not livedb itself; livedb appears to be in maintenance mode with no recent updates.","status":"maintenance","version":"0.5.13","language":"javascript","source_language":"en","source_url":"git://github.com/share/livedb","tags":["javascript"],"install":[{"cmd":"npm install livedb","lang":"bash","label":"npm"},{"cmd":"yarn add livedb","lang":"bash","label":"yarn"},{"cmd":"pnpm add livedb","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"MongoDB backend for persisting documents and ops","package":"livedb-mongo","optional":true},{"reason":"OT types (e.g., json0, text) used for document operations","package":"ottypes","optional":true}],"imports":[{"note":"Package uses CommonJS default export; ESM import requires default import syntax.","wrong":"const livedb = require('livedb')","symbol":"default","correct":"import livedb from 'livedb'"},{"note":"Named export 'client' available; common mistake is to destructure incorrectly.","wrong":"const client = require('livedb').client","symbol":"client","correct":"import { client } from 'livedb'"},{"note":"MemoryDb is exported from 'livedb/client', not the main entry point.","wrong":"import { MemoryDb } from 'livedb'","symbol":"MemoryDb","correct":"import { MemoryDb } from 'livedb/client'"}],"quickstart":{"code":"const livedb = require('livedb');\nconst db = require('livedb-mongo')('localhost:27017/test?auto_reconnect', { safe: true });\n\nconst backend = livedb.client(db);\n\nbackend.fetchAndSubscribe('users', 'fred', function(err, data, stream) {\n  if (err) return console.error(err);\n  console.log('Initial version:', data.v);\n  stream.on('data', function(op) {\n    console.log('Operation received:', op);\n  });\n});\n\nbackend.submit('users', 'fred', { v: 0, create: { type: 'json0', data: { name: 'Fred' } } }, function(err) {\n  if (err) return console.error(err);\n  console.log('Document created');\n  backend.submit('users', 'fred', { v: 1, op: [{ p: ['name', 4], si: ' Flintstone' }] }, function(err) {\n    if (err) return console.error(err);\n    console.log('Edit applied');\n  });\n});","lang":"javascript","description":"Shows how to connect to MongoDB via livedb-mongo, subscribe to a document, and submit create and edit operations using OT."},"warnings":[{"fix":"Consider migrating to sharedb (npm: sharedb) which is the successor.","message":"The v5.x releases (such as v5.2.2) refer to the share/sharedb package, not livedb itself. livedb v0.5.13 is the last known version and may not receive updates.","severity":"breaking","affected_versions":">=0.5.13"},{"fix":"Use a Redis-based driver for multi-server scenarios.","message":"The inprocess driver is default but deprecated for multi-server setups; it does not support cross-process operation publishing.","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Use a persistent backend like livedb-mongo for production.","message":"MemoryDb stores all operations in memory until server restart; data is lost on shutdown.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Initialize livedb with a driver: livedb.client(db, { driver: redisDriver }).","message":"Operations from different servers will not be visible unless a driver (e.g., Redis) is used; otherwise each server only sees its own operations.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install livedb-mongo","cause":"Missing livedb-mongo package when trying to use MongoDB backend.","error":"Error: Cannot find module 'livedb-mongo'"},{"fix":"Use const backend = livedb.client(db); then call backend.submit(...).","cause":"Did not call livedb.client(db) properly; likely imported wrong symbol.","error":"TypeError: backend.submit is not a function"},{"fix":"Install the ot-json0 package and register it: const json0 = require('ot-json0'); livedb.types.register(json0.type);","cause":"OT type json0 not registered or available.","error":"Error: Unsupported OT type 'json0'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}