截至目前,我在\服務器我MongoDB的「選擇」 \ publications.js,如:應該發佈MongoDB插入/更新/ Upserts /刪除嗎?
Meteor.publish("jobLocations", function() {
return JobLocations.find();
});
...和我訂閱那些\客戶端\ main.js,如:
Meteor.startup(function() {
Meteor.subscribe("jobLocations");
. . .
...但我有我的插入/更新/ Upserts /刪除在\既\ methods.js,就像這樣:
Meteor.methods({
'insertJobLocation': function(username, jobLoc, placename, st8OrProvince, postalcode, xcoord, ycoord) {
JobLocations.insert({
jl_jobloc: jobLoc,
. . .
...和我從\客戶打電話給他們\ templates \ whatever.js,如下所示:
'submit form': function(event, template) {
. . .
Meteor.call('insertJobLocation', jobloc, placename, st8OrProvince,
postalcode, xcoord, ycoord, function(err) {
. . .
這是有效的,但它是錯誤的[-headed]?
應該所有 MongoDB的代碼發佈/訂閱(IOW,位於\服務器\ publications.js和\客戶\ main.js?
只訂閱你真正需要的東西。 'Meteor.methods'最終在服務器上執行,您只需發送一個'_id'來真正知道要修改什麼。 –
你是什麼意思?我真的需要一切。 –