tc / RMongo

R client to interface with MongoDB
102 stars 34 forks source link

Switching between databases from authenticate to dbAggregate #24

Open tomschenkjr opened 10 years ago

tomschenkjr commented 10 years ago

It appears the steps, mongoDbConnect -> dbAuthenticate -> dbAggregate limits the use of switching between databases after authentication. For instance, authenticating with "foo" database, then switching to "bar".

username = ""
password = ""
mongo <- mongoDbConnect("foo")
authenticated <- dbAuthenticate(mongo, username, password)
# Following will not run because data is within "bar" database
counts <- dbAggregate(mongo, "collection", ... )
tc commented 10 years ago

Would the workaround of making a second connection be suitable?

mongoConn1 <- mongoDbConnect("foo") mongoConn2 <- mongoDbConnect("bar")