Search code examples
mongodbdocumentmongoimport

Import a whole dataset into one MongoDB document


I'm trying to find a way to import a whole dataset into one MongoDB document. Every solution I've tried only inserts many documents instead of one. What I've tried so far.

mongoimport --db=dbName --collection=collectionName --drop --file=file.json --jsonArray

Thank you in advance!


Solution

  • Problem is solved, thanks to both prasad_ and Joe.

    After using the mongoimport that is shown in my question, I just aggregated using $group to get everything into one document. Though there was a problem which Joe commented, that a document is limited to 16MB. Which meant that I had to remove some data from the dataset that I wasn't using.