or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

administration.mdaql-queries.mddatabase-connection.mddocument-collections.mdgraph-operations.mdindex.mdquery-execution.mdtransactions.mdviews-search.md
tile.json

administration.mddocs/

Administration

Database administration, user management, and system operations for comprehensive ArangoDB server management and monitoring.

Capabilities

User Management

Create and manage database users with role-based access control.

/**
 * Gets a reference to a user
 * @param username - Username
 * @returns User management interface
 */
user(username: string): User;

/**
 * Creates a new database user
 * @param username - Username for the new user
 * @param options - User creation options
 * @returns Promise resolving to user information
 */
createUser(username: string, options?: UserOptions): Promise<ArangoUser>;

/**
 * Lists all users in the database system
 * @returns Promise resolving to array of user information
 */
users(): Promise<ArangoUser[]>;

/**
 * Updates user properties
 * @param username - Username to update
 * @param options - Updated user properties
 * @returns Promise resolving to updated user information
 */
updateUser(username: string, options: UserOptions): Promise<ArangoUser>;

/**
 * Removes a user from the system
 * @param username - Username to remove
 * @returns Promise resolving when user is removed
 */
removeUser(username: string): Promise<void>;

Usage Examples:

import { Database } from "arangojs";

const db = new Database();

// Create new user
const newUser = await db.createUser("alice_dev", {
  passwd: "secure_password_123",
  active: true,
  extra: {
    fullName: "Alice Developer",
    department: "Engineering",
    email: "alice@company.com"
  }
});

console.log("Created user:", newUser.user);

// Get user reference for management
const userRef = db.user("alice_dev");

// List all users
const allUsers = await db.users();
console.log(`Total users: ${allUsers.length}`);

for (const user of allUsers) {
  console.log(`User: ${user.user}, Active: ${user.active}`);
}

// Update user properties
await db.updateUser("alice_dev", {
  active: true,
  passwd: "new_secure_password_456",
  extra: {
    ...newUser.extra,
    lastUpdated: new Date().toISOString()
  }
});

// Eventually remove user
await db.removeUser("alice_dev");

User Access Control

Manage user permissions and database access levels.

/**
 * Gets user access level for a specific database
 * @param username - Username to check
 * @param databaseName - Database name (defaults to current database)
 * @returns Promise resolving to access level
 */
getUserAccessLevel(username: string, databaseName?: string): Promise<AccessLevel>;

/**
 * Sets user access level for a specific database
 * @param username - Username to modify
 * @param databaseName - Database name
 * @param accessLevel - Access level to grant
 * @returns Promise resolving when access is updated
 */
setUserAccessLevel(
  username: string,
  databaseName: string,
  accessLevel: AccessLevel
): Promise<void>;

/**
 * Clears user access for a specific database
 * @param username - Username to modify
 * @param databaseName - Database name
 * @returns Promise resolving when access is cleared
 */
clearUserAccessLevel(username: string, databaseName: string): Promise<void>;

/**
 * Gets user access level for a specific collection
 * @param username - Username to check
 * @param collectionName - Collection name
 * @param databaseName - Database name (defaults to current database)
 * @returns Promise resolving to access level
 */
getUserCollectionAccessLevel(
  username: string,
  collectionName: string,
  databaseName?: string
): Promise<AccessLevel>;

/**
 * Sets user access level for a specific collection
 * @param username - Username to modify
 * @param collectionName - Collection name
 * @param accessLevel - Access level to grant
 * @param databaseName - Database name (defaults to current database)
 * @returns Promise resolving when access is updated
 */
setUserCollectionAccessLevel(
  username: string,
  collectionName: string,
  accessLevel: AccessLevel,
  databaseName?: string
): Promise<void>;

Usage Examples:

// Grant database access
await db.setUserAccessLevel("alice_dev", "myapp_db", "rw");
await db.setUserAccessLevel("bob_analyst", "myapp_db", "ro");

// Check current access level
const aliceAccess = await db.getUserAccessLevel("alice_dev", "myapp_db");
console.log("Alice's access level:", aliceAccess); // "rw"

// Set collection-specific permissions
await db.setUserCollectionAccessLevel("bob_analyst", "sensitive_data", "none");
await db.setUserCollectionAccessLevel("alice_dev", "user_profiles", "rw");

// Check collection access
const bobCollectionAccess = await db.getUserCollectionAccessLevel(
  "bob_analyst", 
  "sensitive_data"
);
console.log("Bob's access to sensitive data:", bobCollectionAccess); // "none"

// Clear access when no longer needed
await db.clearUserAccessLevel("temp_user", "test_db");

Server Information and Monitoring

Retrieve server information and monitor system health.

/**
 * Gets server version and build information
 * @returns Promise resolving to server information
 */
version(): Promise<ServerInfo>;

/**
 * Gets server engine information (RocksDB, etc.)
 * @returns Promise resolving to engine information
 */
engine(): Promise<ServerEngine>;

/**
 * Gets server role in cluster (coordinator, dbserver, etc.)
 * @returns Promise resolving to server role
 */
role(): Promise<ServerRole>;

/**
 * Gets server statistics and metrics
 * @returns Promise resolving to server statistics
 */
statistics(): Promise<ServerStatistics>;

/**
 * Gets server health status
 * @returns Promise resolving to health information
 */
health(): Promise<ServerHealth>;

Usage Examples:

// Get server version
const serverInfo = await db.version();
console.log("ArangoDB version:", serverInfo.version);
console.log("Server mode:", serverInfo.mode);
console.log("License:", serverInfo.license);

// Check server engine
const engineInfo = await db.engine();
console.log("Storage engine:", engineInfo.name);
console.log("Engine version:", engineInfo.version);

// Get server role (important for cluster setups)
const role = await db.role();
console.log("Server role:", role.role);
console.log("Mode:", role.mode);

// Monitor server statistics
const stats = await db.statistics();
console.log("Active connections:", stats.client.httpConnections);
console.log("Memory usage:", stats.system.memoryUsage);
console.log("CPU usage:", stats.system.cpuUsage);

// Check server health
const health = await db.health();
console.log("Server health:", health.health);
console.log("Health details:", health.details);

Log Management

Access and manage server logs for debugging and monitoring.

/**
 * Retrieves server log entries
 * @param options - Log retrieval options
 * @returns Promise resolving to log entries
 */
logs(options?: LogOptions): Promise<LogEntry[]>;

/**
 * Gets current log level configuration
 * @returns Promise resolving to log level settings
 */
getLogLevel(): Promise<Record<string, LogLevel>>;

/**
 * Sets log levels for different components
 * @param levels - Log level configuration
 * @returns Promise resolving to updated log levels
 */
setLogLevel(levels: Record<string, LogLevel>): Promise<Record<string, LogLevel>>;

Usage Examples:

// Get recent error logs
const errorLogs = await db.logs({
  level: "error",
  size: 100,
  offset: 0,
  search: "connection",
  sort: "desc"
});

console.log(`Found ${errorLogs.length} error log entries`);
for (const logEntry of errorLogs) {
  console.log(`[${logEntry.timestamp}] ${logEntry.level}: ${logEntry.message}`);
}

// Get current log levels
const currentLogLevels = await db.getLogLevel();
console.log("Current log levels:", currentLogLevels);

// Increase logging for debugging
await db.setLogLevel({
  general: "debug",
  queries: "trace",
  performance: "info"
});

// Reset log levels after debugging
await db.setLogLevel({
  general: "info",
  queries: "info", 
  performance: "warning"
});

Hot Backup Management

Manage hot backup operations for data protection and disaster recovery.

/**
 * Creates a hot backup of the database
 * @param options - Backup creation options
 * @returns Promise resolving to backup information
 */
createHotBackup(options?: HotBackupOptions): Promise<HotBackupResult>;

/**
 * Lists all available hot backups
 * @returns Promise resolving to array of backup information
 */
listHotBackups(): Promise<HotBackupDescription[]>;

/**
 * Restores from a hot backup
 * @param backupId - ID of the backup to restore
 * @param options - Restore options
 * @returns Promise resolving to restore result
 */
restoreHotBackup(backupId: string, options?: HotBackupRestoreOptions): Promise<HotBackupResult>;

/**
 * Deletes a hot backup
 * @param backupId - ID of the backup to delete
 * @returns Promise resolving when backup is deleted
 */
deleteHotBackup(backupId: string): Promise<void>;

Usage Examples:

// Create a hot backup
const backup = await db.createHotBackup({
  label: "daily_backup_" + new Date().toISOString().split('T')[0],
  allowInconsistent: false,
  timeout: 300 // 5 minutes
});

console.log("Backup created:", backup.id);
console.log("Backup size:", backup.sizeInBytes);

// List all backups
const backups = await db.listHotBackups();
console.log(`Available backups: ${backups.length}`);

for (const backup of backups) {
  console.log(`Backup ${backup.id}:`);
  console.log(`  Created: ${backup.datetime}`);
  console.log(`  Size: ${backup.sizeInBytes} bytes`);
  console.log(`  Collections: ${backup.nrDBServers}`);
}

// Restore from backup (careful!)
const restoreResult = await db.restoreHotBackup(backup.id, {
  timeout: 600 // 10 minutes
});

console.log("Restore completed:", restoreResult.id);

// Clean up old backups
const oldBackups = backups.filter(b => 
  new Date(b.datetime) < new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) // 30 days old
);

for (const oldBackup of oldBackups) {
  await db.deleteHotBackup(oldBackup.id);
  console.log("Deleted old backup:", oldBackup.id);
}

Cluster Administration

Manage cluster operations and coordination (Enterprise Edition).

/**
 * Gets cluster health and status information
 * @returns Promise resolving to cluster health
 */
clusterHealth(): Promise<ClusterHealth>;

/**
 * Gets information about cluster coordinators
 * @returns Promise resolving to coordinator information
 */
coordinators(): Promise<CoordinatorInfo[]>;

/**
 * Gets information about cluster DBServers
 * @returns Promise resolving to DBServer information
 */
dbServers(): Promise<DbServerInfo[]>;

/**
 * Gets cluster maintenance mode status
 * @returns Promise resolving to maintenance mode info
 */
getMaintenanceMode(): Promise<MaintenanceModeInfo>;

/**
 * Enables or disables cluster maintenance mode
 * @param enabled - Whether to enable maintenance mode
 * @returns Promise resolving when mode is changed
 */
setMaintenanceMode(enabled: boolean): Promise<MaintenanceModeInfo>;

Usage Examples:

// Check cluster health
const clusterHealth = await db.clusterHealth();
console.log("Cluster health:", clusterHealth.Health);
console.log("Cluster ID:", clusterHealth.ClusterId);

// List coordinators
const coordinators = await db.coordinators();
console.log(`Coordinators: ${coordinators.length}`);
for (const coord of coordinators) {
  console.log(`Coordinator ${coord.id}: ${coord.address}`);
  console.log(`  Status: ${coord.status}`);
  console.log(`  Version: ${coord.version}`);
}

// List DBServers
const dbServers = await db.dbServers();
console.log(`DBServers: ${dbServers.length}`);
for (const server of dbServers) {
  console.log(`DBServer ${server.id}: ${server.address}`);
  console.log(`  Status: ${server.status}`);
  console.log(`  Used storage: ${server.diskUsage}`);
}

// Enable maintenance mode for cluster operations
const maintenanceInfo = await db.setMaintenanceMode(true);
console.log("Maintenance mode enabled:", maintenanceInfo.enabled);

// Perform maintenance operations...

// Disable maintenance mode
await db.setMaintenanceMode(false);
console.log("Maintenance mode disabled");

Types

interface ArangoUser {
  user: string;
  active: boolean;
  extra: Record<string, any>;
}

interface UserOptions {
  passwd?: string;
  active?: boolean;
  extra?: Record<string, any>;
}

type AccessLevel = "rw" | "ro" | "none";

interface ServerInfo {
  server: string;
  version: string;
  mode: string;
  license: string;
  details: Record<string, any>;
}

interface ServerEngine {
  name: string;
  version: string;
  supports: Record<string, boolean>;
}

interface ServerRole {
  role: "coordinator" | "dbserver" | "agent" | "single";
  mode: "cluster" | "resilient-single";
}

interface ServerStatistics {
  system: {
    memoryUsage: number;
    cpuUsage: number;
    diskUsage: number;
  };
  client: {
    httpConnections: number;
    connectionTime: number;
  };
  database: {
    collections: number;
    documents: number;
    indexes: number;
  };
}

interface ServerHealth {
  health: "good" | "bad";
  details: Record<string, any>;
}

interface LogEntry {
  id: string;
  timestamp: string;
  level: LogLevel;
  topic: string;
  message: string;
}

type LogLevel = "fatal" | "error" | "warning" | "info" | "debug" | "trace";

interface LogOptions {
  level?: LogLevel;
  size?: number;
  offset?: number;
  search?: string;
  sort?: "asc" | "desc";
}

interface HotBackupOptions {
  label?: string;
  allowInconsistent?: boolean;
  timeout?: number;
}

interface HotBackupDescription {
  id: string;
  version: string;
  datetime: string;
  nrFiles: number;
  nrDBServers: number;
  sizeInBytes: number;
  available: boolean;
}

interface HotBackupResult {
  id: string;
  potentiallyInconsistent: boolean;
  sizeInBytes: number;
  datetime: string;
}

interface HotBackupRestoreOptions {
  timeout?: number;
}

interface ClusterHealth {
  Health: "good" | "bad";
  ClusterId: string;
}

interface CoordinatorInfo {
  id: string;
  address: string;
  status: "good" | "bad" | "failed";
  version: string;
  role: "coordinator";
}

interface DbServerInfo {
  id: string;
  address: string;
  status: "good" | "bad" | "failed";
  version: string;
  role: "dbserver";
  diskUsage: number;
  memoryUsage: number;
}

interface MaintenanceModeInfo {
  enabled: boolean;
  reason?: string;
  startTime?: string;
}