Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

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
0
Network Zero
Asked:
Network Zero
  • 2
1 Solution
 
aikimarkCommented:
It's looking for a semicolon at the end of your db.post3.insert statement
0
 
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
 
Network ZeroCloud Engineer Author Commented:
figured it out on my own.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now