node.js - Mongo Creating parent schema with empty array of children -
i have following post schema array of comments.
var newpost = new post({ title: req.body.title, date: date.now(), body: req.body.body, image: req.body.image, comments: {} }) newpost.save(function(err){....) i trying create post, add database no comments yet. (comments added later when user going comment). tried null, {}, nothing works :(
ok figured out, wanted create post empty array of comments had was:
var newpost = new post({ title: req.body.title, date: date.now(), body: req.body.body, image: req.body.image, comments: [] }) newpost.save(function(err){....)
Comments
Post a Comment