jeroen / mongolite

Fast and Simple MongoDB Client for R
https://jeroen.github.io/mongolite/
284 stars 64 forks source link

mongosh works, mongolite does not (server 6.3?) #253

Closed r2evans closed 1 year ago

r2evans commented 1 year ago

I'm able to connect via the mongosh shell and query documents for an easy count. Specifically,

$ mongosh "mongodb+srv://<MYFEED>.mongodb.net" --apiVersion 1 --username <ME>
Enter password: ****************
Current Mongosh Log ID: <MYLOGID>
Connecting to:      mongodb+srv://<credentials>@<MYFEED>.mongodb.net/?appName=mongosh+1.8.2
Using MongoDB:      6.3.1 (API Version 1)
Using Mongosh:      1.8.2

Atlas test> use mydb
switched to db mydb
Atlas erdp> db.raw.count({"sessionInfo.sessionId":"a7983927-9f8e-ed11-a2e9-d094661ab20e","type":"location"})
DeprecationWarning: Collection.count() is deprecated. Use countDocuments or estimatedDocumentCount.
748443

but connecting to the same server, same username/password, same collection/db does not work:

M <- mongolite::mongo(collection = "mydb", db = "raw",
                      url = sprintf(
                        "mongodb+srv://%s:%s@<MYFEED>.mongodb.net",
                        "<ME>", "<MYPASS>"))
M$count('{"sessionInfo.sessionId":"a7983927-9f8e-ed11-a2e9-d094661ab20e","type":"location"}')
# [1] 0

What can I check to see why the R connection finds nothing? (I realize you cannot connect/check this collection.)

r2evans commented 1 year ago

I had collection= and db= reversed, sigh.