Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added dbAuthenticate(rmongo.object,username,password) method.

  • Loading branch information...
commit b06a1df9fa7b52fb81524ecc6ca3a28cc9ff9941 1 parent 65bac93
@tc authored
View
4 DESCRIPTION
@@ -1,8 +1,8 @@
Package: RMongo
Type: Package
Title: MongoDB Client for R
-Version: 0.0.19
-Date: 2011-04-11
+Version: 0.0.20
+Date: 2011-04-22
Author: Tommy Chheng
Maintainer: Tommy Chheng <tommy.chheng@gmail.com>
Description: MongoDB Database interface for R. The interface is provided via Java calls to the mongo-java-driver.
View
2  NAMESPACE
@@ -1,4 +1,4 @@
import('rJava')
export('mongoDbConnect')
exportClass('RMongo')
-exportMethods('dbInsertDocument', 'dbShowCollections', 'dbGetQuery', 'dbGetQueryForKeys', 'dbDisconnect')
+exportMethods('dbInsertDocument', 'dbAuthenticate', 'dbShowCollections', 'dbGetQuery', 'dbGetQueryForKeys', 'dbDisconnect')
View
8 R/rmongo.R
@@ -9,6 +9,14 @@ mongoDbConnect <- function(dbName, host="127.0.0.1", port=27017){
rmongo
}
+setGeneric("dbAuthenticate", function(rmongo.object, username, password) standardGeneric("dbAuthenticate"))
+setMethod("dbAuthenticate", signature(rmongo.object="RMongo", username="character", password="character"),
+ function(rmongo.object, username, password){
+ results <- .jcall(rmongo.object@javaMongo, "Z", "dbAuthenticate", username, password)
+ results
+ }
+)
+
setGeneric("dbShowCollections", function(rmongo.object) standardGeneric("dbShowCollections"))
setMethod("dbShowCollections", signature(rmongo.object="RMongo"),
function(rmongo.object){
View
BIN  inst/java/r-mongo-scala-1.0-SNAPSHOT.jar
Binary file not shown
View
1  man/RMongo-class.Rd
@@ -8,6 +8,7 @@ Contains the mongodb connection information. See mongoDbConnect for creating a R
}
\section{Methods}{
\describe{
+ \item{dbAuthenticate}{}
\item{dbGetQuery}{}
\item{dbGetQueryForKeys}{}
\item{dbInsertDocument}{}
View
3  man/RMongo-package.Rd
@@ -45,7 +45,8 @@ A typical workflow using RMongo:
}
\author{
-Tommy Chheng <tommy@quid.com>
+Tommy Chheng <tommy.chheng@gmail.com>
+http://tommy.chheng.com
}
\keyword{mongodb}
\keyword{mongo}
View
33 man/dbAuthenticate-methods.Rd
@@ -0,0 +1,33 @@
+\name{dbAuthenticate-methods}
+\docType{methods}
+\alias{dbAuthenticate}
+\alias{dbAuthenticate-methods}
+\alias{dbAuthenticate,RMongo-method}
+
+\title{Authenticate with a username/password.}
+
+\description{
+This is an optional authenticate method.
+}
+
+\usage{
+dbAuthenticate(rmongo.object, username, password)
+}
+
+\arguments{
+ \item{rmongo.object}{RMongo object containing the database connection information.}
+ \item{username}{Username}
+ \item{password}{Password}
+}
+
+\seealso{
+ \code{\link{dbAuthenticate}}
+}
+\examples{
+ mongo <- mongoDbConnect("test")
+ username = ""
+ password = ""
+ authenticated <- dbAuthenticate(mongo, username, password)
+ dbDisconnect(mongo)
+}
+
View
4 src/r-mongo-scala/src/main/scala/com/quid/RMongo.scala
@@ -20,6 +20,10 @@ class RMongo(dbName: String, host: String, port: Int) {
def this(dbName: String) = this (dbName, "127.0.0.1", 27017)
+ def dbAuthenticate(username:String, password:String):Boolean = {
+ db.authenticate(username, password.toCharArray)
+ }
+
def dbShowCollections():Array[String] = {
val names = db.getCollectionNames().map(name => name)
Please sign in to comment.
Something went wrong with that request. Please try again.