CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-pouchdb-adapter-http

PouchDB adapter using HTTP for remote CouchDB connections and database operations

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

database-operations.mddocs/

Database Operations

Core database management functionality for establishing connections, retrieving database information, and managing database lifecycle operations.

Capabilities

HttpPouch Constructor

Creates a new HTTP adapter instance connected to a remote database.

/**
 * Creates an HTTP adapter instance for connecting to remote CouchDB
 * @param opts - Configuration options for the database connection
 * @param callback - Callback function called when setup is complete
 */
function HttpPouch(opts, callback);

Usage Examples:

// Basic connection
const db = new PouchDB('http://localhost:5984/mydb');

// With authentication
const db = new PouchDB('http://localhost:5984/mydb', {
  auth: {
    username: 'admin',
    password: 'secret'
  }
});

// With custom headers
const db = new PouchDB('http://localhost:5984/mydb', {
  headers: {
    'Custom-Header': 'value'
  }
});

Database Information

Retrieves comprehensive information about the connected database.

/**
 * Get database information including document counts and metadata
 * @param callback - Callback function receiving database info
 */
api._info(callback): void;

Usage Examples:

db.info((err, info) => {
  if (err) {
    console.error('Error getting database info:', err);
    return;
  }
  
  console.log('Database name:', info.db_name);
  console.log('Document count:', info.doc_count);
  console.log('Update sequence:', info.update_seq);
  console.log('Host URL:', info.host);
});

Database ID Generation

Generates a unique identifier for the database connection.

/**
 * Generate unique database ID based on server UUID and database name
 * @param callback - Callback function receiving the database ID
 */
api.id(callback): void;

Usage Examples:

db.id((err, id) => {
  if (err) {
    console.error('Error getting database ID:', err);
    return;
  }
  
  console.log('Database ID:', id);
});

Database Compaction

Triggers database compaction to reduce storage size and improve performance.

/**
 * Trigger database compaction on the remote server
 * @param opts - Compaction options including polling interval
 * @param callback - Callback function called when compaction completes
 */
api.compact(opts, callback): void;

Usage Examples:

// Basic compaction
db.compact((err, result) => {
  if (err) {
    console.error('Compaction failed:', err);
    return;
  }
  
  console.log('Compaction completed:', result.ok);
});

// With custom polling interval
db.compact({ interval: 500 }, (err, result) => {
  if (err) {
    console.error('Compaction failed:', err);
    return;
  }
  
  console.log('Compaction completed:', result.ok);
});

Database Destruction

Permanently deletes the remote database and all its contents.

/**
 * Delete the remote database permanently
 * @param options - Destruction options (currently unused)
 * @param callback - Callback function called when deletion completes
 */
api._destroy(options, callback): void;

Usage Examples:

db.destroy((err, result) => {
  if (err) {
    console.error('Database destruction failed:', err);
    return;
  }
  
  console.log('Database destroyed:', result.ok);
});

Connection Closure

Closes the database connection and cleans up resources.

/**
 * Close the database connection
 * @param callback - Callback function called when connection is closed
 */
api._close(callback): void;

Usage Examples:

db.close((err) => {
  if (err) {
    console.error('Error closing database:', err);
    return;
  }
  
  console.log('Database connection closed');
});

Types

// Constructor options
interface HttpPouchOptions {
  name: string;
  auth?: AuthOptions;
  headers?: { [key: string]: string };
  fetch?: Function;
  skip_setup?: boolean;
}

interface AuthOptions {
  username: string;
  password: string;
}

// Database info response
interface DatabaseInfo {
  db_name: string;
  doc_count: number;
  doc_del_count: number;
  update_seq: string | number;
  purge_seq: string | number;
  compact_running: boolean;
  disk_size: number;
  data_size: number;
  instance_start_time: string;
  disk_format_version: number;
  committed_update_seq: string | number;
  host: string;
}

// Compact options
interface CompactOptions {
  interval?: number;
}

// Standard result format
interface StandardResult {
  ok: boolean;
}

Install with Tessl CLI

npx tessl i tessl/npm-pouchdb-adapter-http

docs

attachment-operations.md

changes-feed.md

database-operations.md

document-operations.md

http-utilities.md

index.md

tile.json