0
在下面的Meteor服務器代碼中,它編譯時打印出從myCol
獲取的顏色。但是顏色被mongo shell命令改變了,並且代碼被再次激發,它無法打印出新的顏色。
如何修復它以便console.log(color)
打印「新」顏色? THXJavascript模塊以公開方法引用收集文檔
///////sever/food.js
let Milk = function() {
let color = Meteor.myCol.findOne({food:'milk'}).color;
return function() {
console.log (color);
}
}
export const Food = {
milk: new Milk()
}
//////server/buy.js
import {Food} from './food';
Food.milk(); // expecting to get the color saved in the collection at the time of calling