Class: PgRest::ColumnsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/pg_rest/columns_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_request!

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/pg_rest/columns_controller.rb', line 8

def create   
  result = PgService.add_column(
    table_name: params[:table_id],
    name: pg_params[:name],
    type: pg_params[:type],
    default: pg_params[:default],
    array: pg_params[:array],
    primary_key: pg_params[:primary_key],
    foreign_key: pg_params[:foreign_key]
  )
  render json: { message: 'Column added.', data: result }
end

#destroyObject



21
22
23
24
25
26
27
# File 'app/controllers/pg_rest/columns_controller.rb', line 21

def destroy  
  result = PgService.remove_column(
    table_name: params[:table_id],
    name: params[:id]
  )
  render json: { message: 'Column removed.', data: result }
end