how can i do this $find in RStudio for a collection of a database that is in the free MongoDB atlas cluster?
0
votes
0
answers
11
views
I created a shiny application on RStudio and to manage the database I linked them to mongodb compass. Co,,e I wanted to put my application on shinyapps, I found it wise to put the database on mongodb atls. And to link mongodb atlas to RStudio I put this in the code
# Connection to the MongoDB database
mongo_db_user <- "wambejordan13"
mongo_db_password <- "hPJdzfQA54fhkH6A"
mongo_database <- "élection"
mongo_collection <- "mycollection"
mongo_clustername <- "cluster0.s4gje.mongodb.net"
# the following is the connection string for an Atlas online MongoDB cluster
url_path = sprintf("mongodb+srv://%s:%s@%s/admin",
mongo_db_user, mongo_db_password, mongo_clustername)
votants <- mongo(collection = "votant", url = url_path)
candidats <- mongo(collection = "candidat", url = url_path, options = ssl_options(weak_cert_validation = TRUE))
electeurs <- mongo(collection = "électeur", url = url_path, options = ssl_options(weak_cert_validation = TRUE))
candidat_delegue <- mongo(collection = "candidatDélégué", url = url_path)
electeurs23 <- mongo(collection = "électeurDélégué", url = url_path)
But this error appears when I run the code
Error in : (Unauthorized) not authorized on admin to execute command { find: "candidat", filter: { }, projection: { _id: 0 }, sort: { }, skip: 0, limit: 0, noCursorTimeout: false, $db: "admin", lsid: { id: {4 [123 30 43 183 43 234 79 157 153 244 216 50 3 40 204 106]} }, $clusterTime: { clusterTime: {1727183562 2}, signature: { hash: {0 [206 172 38 240 70 44 96 154 49 112 242 104 8 13 139 227 99 180 206 249]}, keyId: 7354479715932962816.000000 } } }
I already had to modify the user privileges at the mongodb atlas level and I put readWrite but it did not change.
Asked by valere
(1 rep)
Sep 26, 2024, 10:59 AM