ArewegoodQ ArewegoodQ - 1 year ago 147
Node.js Question

Document insert with Mongoose

Here's my Mongoose schema:

var DealSchema = new Schema({
type: String,
require: true,
unique: true,
title: String,

// Embedded sub-document
details: {
detail: String,
price: Number // USE: deal.details.price

My insert statement is as follows:{
deal.dealid: '1',
deal.title: 'deal',

details.detail: 'Free Food',
details.price: 200

The error I am getting:

SyntaxError: missing : after property id @(shell):2:4

Not sure what this error means - how can I fix it?

Answer Source

Your object syntax in the insert is incorrect - it needs to be proper JSON, unless you use dot notation as @krl explained.

Assuming you're using Mongoose:{
    deal: {
        dealid: '1',
        title: 'deal'
    details: {
        detail: 'Free Food',
        price: 200
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download