DebugDBProviderclass

new DebugDBProvider<I, T>()
Return
DebugDBProvider<I, T>
Database provider that logs every operation it performs to the console for debugging.

Database provider that logs every operation it performs to the console for debugging.

  • Wraps a source provider and writes console.debug lines (with ANSI direction markers) before and after each call, and console.error on failure.
  • Drop it into a provider chain while developing to trace database reads and writes; it changes no data.

A wrapping provider that logs every database operation to the console with ANSI formatting. DebugDBProvider extends ThroughDBProvider and is a development aid — drop it into a chain to see each read and write as it happens.

Usage

ts
import { DebugDBProvider, MemoryDBProvider } from "shelving/db";

const provider = new DebugDBProvider(new MemoryDBProvider());

await provider.addItem(POSTS, { title: "Hello", body: "…", published: false });
// Console shows the addItem operation and its result.

Examples

const provider = new DebugDBProvider(new MemoryDBProvider());
 await provider.getItem(users, 123); // Logs the call and its result.