MongoDB - Insert Document syntax errors

MongoDB collection insert document fails

I'm not sure why its failing.

db.post3.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',
      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 
     }
   ]
}
])

Open in new window

fail.jpg
LVL 8
Network ZeroCloud Engineer Asked:
Who is Participating?
 
Network ZeroCloud Engineer Author Commented:
I figured it out on my own after doing a lot of mongodb training for about a day. it's the apostrophe in the word doesn't.

db.post3.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',
      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 
     }
   ]
}
])

Open in new window

0
 
aikimarkCommented:
It's looking for a semicolon at the end of your db.post3.insert statement
0
 
Network ZeroCloud Engineer Author Commented:
figured it out on my own.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.