Importing JSON file using mongimport, keep getting `unexpected identifier`?

前端 未结 2 488
闹比i
闹比i 2020-12-13 19:08

I\'m trying to add a JSON file to mongodb using mongoimports from terminal, here:

 mongoimport --db my_db --collection my_collection --file /con         


        
相关标签:
2条回答
  • 2020-12-13 19:23

    Answering my own question because complete newbies will appreciate the error and may run into it as they get started.

    mongoimport is used from terminal, NOT within the mongo shell. Just like you don't use npm inside node. ;D

    After figuring out my conceptual error there, I needed --jsonArray as pointed to by @WiredPrairie in the comments.

    0 讨论(0)
  • 2020-12-13 19:41

    The following command from terminal worked good for me:

    mongoimport -d my_db -c my_collection < /content/2_read.json --batchSize 1
    
    0 讨论(0)
提交回复
热议问题