Monday, 24 April 2017

Hot to use Object in mongoose Schemas?

I have Schema:

var someSchema = new Schema({
    data: {
        nickname: {type: String},
        id: Schema.Types.ObjectId,
        message: { type: String},
    },
    createdAt: { type: Date, default: Date.now }
});

But when I am trying to use it:

some.collection.insert({data.nickname: nickname, data.message: message,}, function (err, doc) {
  if (err) {
      console.log("Something wrong !");
  }
  res.redirect('/');
});

I have an error: SyntaxError: Unexpected token .

How to insert data to my Object?



via Bim Bam

No comments:

Post a Comment