Importing data into mongodb
- To import the json documents.
prabin@linux:~$ mongoimport "/home/prabin/Downloads/Thapa Technical MongoDB Import Files/products.json" -d shop -c products
2023-09-08T12:36:15.812+0530 connected to: mongodb://localhost/
2023-09-08T12:36:16.181+0530 10355 document(s) imported successfully. 0 document(s) failed to import.
- To import array of json documents use --jsonArray flag.
prabin@linux:~$ mongoimport "/home/prabin/Downloads/Thapa Technical MongoDB Import Files/sales.json" -d shop -c sales
2023-09-08T12:37:55.806+0530 connected to: mongodb://localhost/
2023-09-08T12:37:55.807+0530 Failed: cannot decode array into a primitive.D
2023-09-08T12:37:55.807+0530 0 document(s) imported successfully. 0 document(s) failed to import.
prabin@linux:~$ mongoimport "/home/prabin/Downloads/Thapa Technical MongoDB Import Files/sales.json" -d shop -c sales --jsonArray
2023-09-08T12:38:06.957+0530 connected to: mongodb://localhost/
2023-09-08T12:38:06.977+0530 5 document(s) imported successfully. 0 document(s) failed to import.
- Limits of import is 16 mb or smaller.