jeroen / mongolite

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

Find and Iterate gives different data #192

Closed m-santh closed 4 years ago

m-santh commented 4 years ago

MongoDB have a multiple nested arrary. When i use find to get the record, of of the arrary gives the below output

formData$fileMapper ae7c97e4-05f1-4633-87ae-66c66d2611b1 fd1ba3ab-ad57-45fe-816d-6d5f77fdbda1 c64dd0bb-dc35-4444-92b7-87e26046e81e 10 41a33d73-a1a1-47ce-88da-886009ee6bf7 88e10855-ad06-42cf-a4b0-4ef89f7256bd 021cdee1-25ab-419a-a77c-61cfa68151a9 10 f9ed3149-7203-4274-b1df-7d12d67d915c 82ccc081-83a5-4097-ad50-22198b235c94 e2155980-2ed4-4006-876a-b8a967cae737 10 afde94b2-ac61-4a71-aae9-b27eb55116a1 93805448-e9ed-4c09-93a9-48971ffda677 ee472b86-a43b-42c8-adef-d499eca52dce 10 b7791348-ff90-4bc5-8fe0-18b500fddc56 856b66cd-8834-4342-a41b-f36cde40e775 5d0661a3-3b5d-45e4-86be-0336bfa26698 10 51f67e2f-1ea9-41db-a4df-52db06ff19af 10

If you see, i get NA's for all the values (which is a url)

When i use iterator and get one of the record, i get the correct values as shown below

tt3$fileMapper $ae7c97e4-05f1-4633-87ae-66c66d2611b1 [1] "https://assistfilestorage.blob.core.windows.net/e8f065ce-6b4f-40e1-9ccd-b65048f52e28-file-storage/ae7c97e4-05f1-4633-87ae-66c66d2611b1"

$fd1ba3ab-ad57-45fe-816d-6d5f77fdbda1 [1] "https://assistfilestorage.blob.core.windows.net/e8f065ce-6b4f-40e1-9ccd-b65048f52e28-file-storage/fd1ba3ab-ad57-45fe-816d-6d5f77fdbda1"

I am not able to covert the output of iterator to the similar dataframe as find. I want to use similar to output of find with correct values

Would really appreciate any suggestions

jeroen commented 4 years ago

The difference between find() and iterate() is that the former tries to convert the result in a big data frame, whereas the latter gives you lists.

You example code is not clear enough to understand for me what is going on. I don't see any NA's in your example output. If you want me to help, you need to provide example code that creates a demo collection with dummy data so that I can reproduce the problem.

I am not able to covert the output of iterator to the similar dataframe as find. I want to use similar to output of find with correct values

Why not? You can use the from the iterate output to build up the data frame?