mix selecto.gen.saved_views (selecto_mix v0.4.2)

Generate SavedViews behavior implementation for SelectoComponents.

This task generates the necessary files to implement persistent saved views functionality in your SelectoComponents application.

Examples

# Generate for MyApp with default naming
mix selecto.gen.saved_views MyApp

# Generate with custom context module name  
mix selecto.gen.saved_views MyApp --context-module MyApp.CustomSavedViewContext

# Generate with custom schema module name
mix selecto.gen.saved_views MyApp --schema-module MyApp.CustomSavedView

# Generate with custom table name
mix selecto.gen.saved_views MyApp --table-name custom_saved_views

# Show what would be generated without creating files
mix selecto.gen.saved_views MyApp --dry-run

Options

  • --context-module - Name for the context module (default: APP.SavedViewContext)
  • --schema-module - Name for the schema module (default: APP.SavedView)
  • --table-name - Database table name (default: saved_views)
  • --repo-module - Repository module name (default: APP.Repo)
  • --dry-run - Show what would be generated without creating files

Generated Files

This task generates:

  • Migration file for the saved_views table
  • Ecto schema module for SavedView
  • Context module implementing SelectoComponents.SavedViews behavior

Usage in Domains

After running the generator, use the context in your domains:

defmodule MyApp.Domains.UserDomain do
  use MyApp.SavedViewContext

  # ... rest of domain configuration
end

Then in your LiveView, set the saved_view_context assign:

def mount(_params, _session, socket) do
  socket = assign(socket, saved_view_context: MyApp.Domains.UserDomain)
  # ... rest of mount logic
end