Module: Dbviewer::DatabaseOperations::TableOperations

Extended by:
ActiveSupport::Concern
Included in:
Dbviewer::DatabaseOperations
Defined in:
app/controllers/concerns/dbviewer/database_operations/table_operations.rb

Instance Method Summary collapse

Instance Method Details

#fetch_table_columns(table_name) ⇒ Object

Get column information for a specific table



19
20
21
# File 'app/controllers/concerns/dbviewer/database_operations/table_operations.rb', line 19

def fetch_table_columns(table_name)
  database_manager.table_columns(table_name)
end

#fetch_table_metadata(table_name) ⇒ Object

Get table metadata for display (e.g., primary key, foreign keys, indexes)



34
35
36
# File 'app/controllers/concerns/dbviewer/database_operations/table_operations.rb', line 34

def (table_name)
  database_manager.(table_name)
end

#fetch_table_record_count(table_name, column_filters = {}) ⇒ Object

Get filtered record count for a table



29
30
31
# File 'app/controllers/concerns/dbviewer/database_operations/table_operations.rb', line 29

def fetch_table_record_count(table_name, column_filters = {})
  database_manager.table_record_count(table_name, column_filters)
end

#fetch_table_records(table_name, query_params) ⇒ Object

Fetch records for a table with pagination and sorting



24
25
26
# File 'app/controllers/concerns/dbviewer/database_operations/table_operations.rb', line 24

def fetch_table_records(table_name, query_params)
  database_manager.table_records(table_name, query_params)
end

#fetch_tables(include_record_counts = false) ⇒ Object

Fetch all tables with their stats By default, don’t include record counts for better performance on sidebar



8
9
10
11
12
13
14
15
16
# File 'app/controllers/concerns/dbviewer/database_operations/table_operations.rb', line 8

def fetch_tables(include_record_counts = false)
  all_table_names = database_manager.tables
  filtered_table_names = filter_accessible_tables(all_table_names)
  filtered_table_names.map do |table_name|
    table_stats = { name: table_name }
    table_stats[:record_count] = fetch_table_record_count(table_name) if include_record_counts
    table_stats
  end
end