Created
October 8, 2017 16:02
-
-
Save NMZivkovic/ea4a6998ca923e0723f6b32ed1a1178f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
// Define a schema. | |
var userSchema = new Schema({ | |
name: String, | |
blog: String, | |
age: Number, | |
location: String | |
}); | |
// Define a method for concatanation of name and blog fields. | |
userSchema.methods.concatanceNameAndBlog = function() { | |
// Extend name with value of the blog field. | |
this.name = this.name + this.blog; | |
return this.name; | |
}; | |
// Create a model. | |
var User = mongoose.model('User', userSchema); | |
module.exports = User; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment