Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cdbRemoveDB() now should look on the existing DBs
modified: R4CouchDB/R/cdbIni.R modified: R4CouchDB/R/cdbListDB.R modified: R4CouchDB/R/cdbRemoveDB.R
- Loading branch information
wactbprot
committed
Sep 21, 2009
1 parent
e6fd29c
commit 4e44d9d
Showing
3 changed files
with
47 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,45 @@ | ||
cdbRemoveDB <- function(cdb){ | ||
|
||
if(cdb$serverName == ""){ | ||
cdb$error <- paste(cdb$error," no cdb$serverName given") | ||
} | ||
|
||
if(cdb$removeDBName == ""){ | ||
cdb$error <- paste(cdb$error, "no cdb$removeDBName given") | ||
}else{ | ||
|
||
DBNames <- cdbListDB(cdb)$res | ||
DBexists <- which(DBNames == cdb$removeDBName) | ||
|
||
if(length(DBexists) == 0){ | ||
|
||
cdb$error <- paste(cdb$error, | ||
" there is no cdb$removeDBName to delete") | ||
|
||
} | ||
} | ||
|
||
if( cdb$error == ""){ | ||
|
||
if(cdb$DBName == ""){ | ||
adrString <- paste("http://", | ||
cdb$serverName,":", | ||
cdb$port,"/", | ||
cdb$removeDBName, | ||
sep="") | ||
|
||
cdb$error <- "no cdb$DBName to remove" | ||
return(cdb) | ||
}else{ | ||
res <- getURLContent(adrString, | ||
.opts = list(customrequest = "DELETE") | ||
) | ||
|
||
adrString <- paste("http://", | ||
cdb$serverName,":", | ||
cdb$port,"/", | ||
cdb$DBName, | ||
sep="") | ||
cdb$res <- fromJSON(res) | ||
|
||
res <- getURLContent(adrString, .opts = list(customrequest = "DELETE")) | ||
cdb$res <- fromJSON(res) | ||
cdb$DBName <- "" | ||
## the DB should be history | ||
cdb$removeDBName <- "" | ||
return( cdb ) | ||
|
||
} | ||
|
||
}else{ | ||
return(cdb) | ||
} | ||
print(cdb$error) | ||
return(cdb) | ||
} | ||
} |