Open koheiw opened 7 months ago
When I was looking for a way to get one big list from aggreagate(), I saw #236. I think handler should work in this way.
aggreagate()
handler
library(mongolite) con <- mongo("mtcars", url = "mongodb+srv://readwrite:test@cluster0-84vdt.mongodb.net/test") if(con$count() > 0) con$drop() con$insert(mtcars) #> List of 5 #> $ nInserted : num 32 #> $ nMatched : num 0 #> $ nRemoved : num 0 #> $ nUpserted : num 0 #> $ writeErrors: list() # data.frame con$aggregate('[{"$match": {}}, {"$project": {"mpg": 1, "cyl": 1}}]')[1:2,] #> _id mpg cyl #> 1 656a87c6ab879540600b9221 21 6 #> 2 656a87c6ab879540600b9222 21 6 # list con$aggregate('[{"$match": {}}, {"$project": {"mpg": 1, "cyl": 1}}]', handler = as.list)[1:2] #> [[1]] #> [[1]]$`_id` #> [1] "656a87c6ab879540600b9221" #> #> [[1]]$mpg #> [1] 21 #> #> [[1]]$cyl #> [1] 6 #> #> #> [[2]] #> [[2]]$`_id` #> [1] "656a87c6ab879540600b9222" #> #> [[2]]$mpg #> [1] 21 #> #> [[2]]$cyl #> [1] 6
Created on 2023-12-02 with reprex v2.0.2
When I was looking for a way to get one big list from
aggreagate()
, I saw #236. I thinkhandler
should work in this way.Created on 2023-12-02 with reprex v2.0.2