Sha256: 33a1e203fa5356398f85c4eff2c2033b5015785594cb613b28f4afbc0a4ada70

Contents?: true

Size: 773 Bytes

Versions: 1

Compression:

Stored size: 773 Bytes

Contents

class CouchConsole
  def init
    puts "** initialize delete"
    @commands << {
      :regexp => /^\s*delete\s*([^\s]*)\s*([^\s]*)\s*$/,
      :method => :delete,
      :documentation => [["delete id [field]", "Delete the document with id or the field in the document"]]
    }
  end
  
  def delete( id, field )
    document = @db.get( id )
    if field.size > 0
      document.delete(field)
      document.save
      puts "*** Field `#{field}' deleted in document `#{id}'"
    else
      if document.class == CouchRest::Document
        document.destroy
        puts "*** Document `#{id}' deleted"
      else
        puts "!!! Can't delete document `#{id}'"
      end
    end
  rescue RestClient::ResourceNotFound
    puts "!!! Document `#{id}' does not exist."
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
couchc-0.1.0 lib/commands/delete.rb