2016-06-14 11 views
2

mongoシェルに複数の行を単にコピー・ペーストするだけです。スクリプトファイルを使用する唯一の方法はありますか?私はすぐにデータの束を挿入したいのですが、以下が起こる:あなたの元のクエリで複数行のコピーをmongoシェルにコピー

> 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 

> ]) 

答えて

2

修正この行を:

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

を次のように:

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

次にコピー貼り付けは機能します。問題は引用符です。

関連する問題