0
比方說,我有一個模式和對象是這樣的:在Mongoose中,document.get(「nested.value」),document.get(「nested」).value和document.nested.value有什麼區別?
var documentSchema = new mongoose.Schema({
simple: { type: String },
nested: {
value: { type: Number }
}
};
的區別是什麼那麼下面哪一個我應該使用之間?
console.log(document.nested.value);
console.log(document.get('nested').value);
console.log(document.get('nested.value'));
它們都產生相同的結果。我想我應該使用get()
,但有人可以解釋爲什麼?