How do I simply copy-paste multiple lines into the mongo shell. Is the only way to use a script file? I want to quickly insert a bunch of data, but the below happens:
> db.mycollection.insert([
... {
... title: 'MongoDB Overview',
... description: 'MongoDB is no sql database',
... by: 'tutorials point',
... url: 'http://www.tutorialspoint.com',
... tags: ['mongodb', 'database', 'NoSQL'],
... likes: 100
... },
...
... {
... title: 'NoSQL Database',
... description: 'NoSQL database doesn't have tables',
2016-06-14T17:40:30.303+0100 E QUERY [thread1] SyntaxError: missing } after property list @(shell):13:41
> by: 'tutorials point',
... url: 'http://www.tutorialspoint.com',
... tags: ['mongodb', 'database', 'NoSQL'],
... likes: 20,
... comments: [
... {
... user:'user1',
... message: 'My first comment',
... dateCreated: new Date(2013,11,10,2,35),
... like: 0
... }
... ]
2016-06-14T17:40:30.335+0100 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):2:9
> }
2016-06-14T17:40:30.344+0100 E QUERY [thread1] SyntaxError: expected expression, got '}' @(shell):1:0
> ])
Fix this line in your original query:
description: 'NoSQL database doesn't have tables',
To the following:
description: "NoSQL database doesn't have tables",
Then copy and pasting will work. The issue is the quotation marks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With