Mario
unread,Jan 16, 2012, 10:49:34 AM1/16/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Mongoose Node.JS ORM
I have the following mongoose schema:
var Document = new Schema({
name : {type: String, default: 'Untitled'}
});
var User = new Schema({
name : {type: String, default: 'Erik'},
docs : [Document],
created : {type: Date, 'default': Date.now},
lastModified : {type: Date, 'default': Date.now}
});
Is is possible to make an one document by default in 'docs' array when
creating an new user?
I mean when I do User.create() I want to get the following document in
MongoDB
{
_id: ObjectId(...),
name: Erik,
docs: [
{
name: 'Untitled'
}
],
created: 2012-01-15,
lastModified:2012-01-15
}