How to do mongoimport from terminal

0

Hi, I'd like to insert two documents into my database in my 'movieList' collection, but that's not how it works and I do not know why, I could do it from robomongo, but I want to do mongoimport --db movies --collection --movieList - file movies.json I get an error that my document starts with 'd' (Failed: error processing document # 1: invalid character 'd' looking for beginning of value), I thought it could be imported like this ...

db.getCollection("movieList").insertMany([
{"nombre": "Pirates of the Caribbean",
  "cast": ["Leonardo Di Caprio", "Johnny Depp", "Jennifer Anniston"],
  "director": {
    "nombre": "Christopher nolan",
    "contacto":[
      {
        "tipo": "personal",
        "direccion": "calle isaac albeniz 15, Madrid"
      },
      {
        "tipo": "oficina",
        "direccion": "calle lagasca 67, Madrid"
      }
    ]
  },
  "rating": 8,
  "genero": ["Accion", "Aventuras"]

},
{
  "nombre": "Pirates of the Caribbean",
  "cast": ["Leonardo Di Caprio", "Johnny Depp", "Jennifer Anniston"],
  "director": {
    "nombre": "Christopher nolan",
    "contacto":[
      {
        "tipo": "personal",
        "direccion": "calle isaac albeniz 15, Madrid"
      },
      {
        "tipo": "oficina",
        "direccion": "calle lagasca 67, Madrid"
      }
    ]
  },
  "rating": 8,
  "genero": ["Accion", "Aventuras"]
}]);
    
asked by francisco dwq 02.04.2018 в 17:57
source

1 answer

0
  

To do a restore:

  • A single Collection:
  • mongorestore --nsInclude base.coleccion dumb /

  • All Collections
  • mongorestore -h 127.0.0.1:27017 -d newbasebasebase

      

    To make a Backup

  • A single Collection:
  • mongodump -d p -h 127.0.0.1:27017 -d base - collection collection

  • All Collections
  • mongodump -d p -h 127.0.0.1:27017 -d base

        
    answered by 02.04.2018 в 18:32