Sha256: 7a8c34b6edde3735c7c9ed68d65d40e96162992293830ae7f503bd63f2c47dcf

Contents?: true

Size: 1.74 KB

Versions: 6

Compression:

Stored size: 1.74 KB

Contents

module Databases
  
  # ---------------------------------------------------------------------------  
  get "/databases/:page" do
    page       = params[:page].to_i || 1
    path_names = session[:path_names]
    tokens     = path_names.split( "|" )
    
    # Could be we have a cltn path. if so adjust for it
    if tokens.size > 3
      tokens.pop
      session[:path_names] = tokens.join( "|") 
      path_names           = session[:path_names]      
      path_ids             = session[:path_ids].split( "|" )
      path_ids.pop
      session[:path_ids]   = path_ids.join( "|" )
    end 
      
    @cltns     = options.connection.paginate_db( path_names, page, 10 )
    @back_url  = "/explore/back"
    
    erb :'databases/list'
  end
  
  # ---------------------------------------------------------------------------
  get "/databases/collection/:name/" do
    cltn_name  = params[:name]
    path_names = session[:path_names]
    path_ids   = session[:path_ids]
    
    update_paths!( path_ids + "|" + cltn_name, path_names + "|" + cltn_name )

    redirect "/collections/1"
  end
      
  # ---------------------------------------------------------------------------  
  get "/databases/drop/" do
    path_names = session[:path_names]
    options.connection.drop_db( path_names )
    
    redirect "/explore/back"
  end

  # ---------------------------------------------------------------------------  
  post "/databases/delete/" do
    path = params[:path]    
 
    options.connection.drop_cltn( session[:path_names] + "|" + path )
    
    flash_it!( :info, "Collection #{path} was dropped successfully!" )        
    
    @cltns = options.connection.paginate_db( session[:path_names], 1, 10 )    
  
    erb :'databases/results.js', :layout => false
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongo3-0.1.5 lib/controllers/databases.rb
mongo3-0.1.4 lib/controllers/databases.rb
mongo3-0.1.3 lib/controllers/databases.rb
mongo3-0.1.2 lib/controllers/databases.rb
mongo3-0.1.1 lib/controllers/databases.rb
mongo3-0.1.0 lib/controllers/databases.rb