Let’s say I have a Schema and object like this:
var documentSchema = new mongoose.Schema({
simple: { type: String },
nested: {
value: { type: Number }
}
};
What is the difference then between the following and which one should I use?
console.log( document.nested.value );
console.log( document.get('nested').value );
console.log( document.get('nested.value') );
They all produce the same result. I assume I should use get() but can someone explain why?
getcan take a second parameter to support dynamic casting, but if you don’t need that then there isn’t typically a need to usegetdirectly as the dot notation is equivalent and cleaner.