CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-mikro-orm--cli

Command-line interface tool for MikroORM TypeScript ORM providing database management, migrations, schema operations, and entity generation

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

cache.mddocs/

Cache Commands

MikroORM CLI cache management commands for handling metadata cache operations. The metadata cache improves startup performance by caching entity metadata discovery results.

Capabilities

Clear Metadata Cache

Clears the existing metadata cache. Useful when metadata has changed or cache corruption is suspected.

/**
 * Clear metadata cache command
 */
command: "cache:clear"

// No additional options beyond global options

Usage Examples:

# Clear cache with default configuration
mikro-orm cache:clear

# Clear cache with specific config file
mikro-orm cache:clear --config ./custom-config.js

# Clear cache for specific context
mikro-orm cache:clear --context production

Generate Metadata Cache

Generates metadata cache for improved application startup performance. Supports both development and production cache formats.

/**
 * Generate metadata cache command
 */
command: "cache:generate"

interface CacheGenerateOptions extends BaseArgs {
  ts?: boolean;        // Use ts-node to generate '.ts' cache
  tsNode?: boolean;    // Alias for ts
  combined?: string;   // Generate production cache into single JSON file
  c?: string;         // Alias for combined
}

Usage Examples:

# Generate standard cache
mikro-orm cache:generate

# Generate TypeScript cache for development
mikro-orm cache:generate --ts-node

# Generate production cache into single file
mikro-orm cache:generate --combined

# Generate cache with custom config
mikro-orm cache:generate --config ./orm.config.js --combined

Command Options

Global Options

All cache commands support:

  • --config / -c: Path to ORM configuration file(s)
  • --contextName / --context: Configuration context name

cache:generate Options

  • --ts-node / --ts: Generate TypeScript-compatible cache (for development)
  • --combined / -c: Generate production cache into single JSON file that can be used with GeneratedCacheAdapter

Error Handling

cache:clear Errors

  • Cache not enabled: If metadata cache is disabled in configuration, the command will display an error message and exit
  • Configuration errors: Invalid or missing configuration will prevent cache operations

cache:generate Errors

  • Entity discovery failures: Problems discovering entities will prevent cache generation
  • File system errors: Insufficient permissions or disk space can cause cache generation to fail
  • TypeScript compilation errors: When using --ts-node, TypeScript compilation issues will prevent cache generation

Related Configuration

Cache commands work with these MikroORM configuration options:

interface CacheConfiguration {
  metadataCache: {
    enabled: boolean;           // Enable/disable cache
    adapter: CacheAdapter;      // Cache adapter instance
    options?: {
      combined?: string;        // Path for combined cache file
    };
  };
}

docs

cache.md

database.md

debug.md

entities.md

helper-api.md

index.md

migrations.md

schema.md

seeders.md

tile.json