ArewegoodQ ArewegoodQ - 4 months ago 16x
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?


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