多行复制粘贴到 mongo shell

dar*_*ace 5 linux bash terminal mongodb

我如何简单地将多行复制粘贴到 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

> ])
Run Code Online (Sandbox Code Playgroud)

Kai*_*rat 2

修复原始查询中的这一行:

description: 'NoSQL database doesn't have tables',
Run Code Online (Sandbox Code Playgroud)

至以下内容:

description: "NoSQL database doesn't have tables",
Run Code Online (Sandbox Code Playgroud)

然后复制粘贴就可以了。问题是引号。