2016-06-14 5 views
2

Wie kopiere ich einfach mehrere Zeilen in die Mongo Shell. Ist die einzige Möglichkeit, eine Skriptdatei zu verwenden? Ich möchte eine Reihe von Daten schnell einfügen, aber die unten passiert:Multiline Kopie-Paste zu Mongo Shell

> 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 

> ]) 

Antwort

2

Fix diese Zeile in Ihrer ursprünglichen Abfrage:

description: 'NoSQL database doesn't have tables', 

auf die folgenden:

description: "NoSQL database doesn't have tables", 

Dann kopieren und das Einfügen wird funktionieren. Das Problem sind die Anführungszeichen.

Verwandte Themen