Pasting into mongoDB shell is not working correctly

33 views Asked by At

I'm trying to learn mongodb and when I try to paste json into the shell to insert many I get a token error. I'm trying to paste this:

[
  {
    "departureAirport": "MUC",
    "arrivalAirport": "SFO",
    "aircraft": "Airbus A380",
    "distance": 12000,
    "intercontinental": true
  },
  {
    "departureAirport": "LHR",
    "arrivalAirport": "TXL",
    "aircraft": "Airbus A320",
    "distance" : 950,
    "intercontinental": false
  }
]

when I paste it though it returns this:

flights> db.flights.insertMany([
stance" : 950,
...   {
...     "departureAirport": "MUC",
...     "arrivalAirport": "SFO",
...     "aircraft": "Airbus A380",
...     "distance": 12000,
...     "intercontinental": true
...   },
...   {
...     "departureAirport": "LHR",
...     "arrivalAirport": "TXL",
...     "aircraft": "Airbus A320",
...     "di    "intercontinental": false
Uncaught:
SyntaxError: Unexpected token (13:12)

  11 |     "arrivalAirport": "TXL",
  12 |     "aircraft": "Airbus A320",
> 13 |     "di    "intercontinental": false
     |             ^
  14 |

flights>   }

For some reason it is taking the distance from the second entry and pasting it in front of the objects I'm trying to create. I'm coping from VS code.

It throws up the error before I can adjust the second object. I have tried using ctl+insert and shift+insert as well as clt+c and ctl+v.Idk why the shell isn't allowing the objects to be copied correctly. I used ctl+c and ctl+v to add the code to the stack overflow post so I think it's the shell that's having the problem.

0

There are 0 answers