KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am new to Node.js, mongodb and mongoose. I want to pass some parameter in creating a new document. For example, that is the typical example of creating a new document: var animalSchema = new Schema({ name: String, type: String }); var Animal = mongoose.model('Animal', animalSchema); var dog = new Animal({ type: 'dog' }); And I want do something like this: var dog = new Animal( Array ); So I want to create custom constructor for a new document. But I dont know where and how I can set a custom constructor like that in mongoose. I have a stackoverflow post with a similar name but it seems not be something that I want: Custom constructor function in Mongoose schema/models Maybe I make a silly mistake. Welcome to any ideas. Thanks
Tags (comma-separated)
Save Edits
Cancel