0

コレクションを更新しようとすると、Meteor はサーバー上で次の例外をスローします。

Exception while invoking method '/reports/update' Error: 
    Did not check() all arguments during call to '/reports/update'

呼び出しは非常に簡単です。

Reports.update({ _id : this._id },{ $set : query });

アップデート:

更新前に「チェック」を追加してみました

2 つのバージョンが同じ結果で試行されました: 例外は引き続きバージョン 1 でスローされます

check(query, Match.Any);

バージョン 2

var update = { $set : query };
check(update, Match.Any);

コレクションには、何でも許可するように定義された allow メソッドがあります。

  Reports.allow({
     insert: function(){
        return true;
     },
     update: function(){
        return true;
     },
     remove: function(){
        return true;
     }
  })

どこに置くことができcheck(query, Match.Any)ますか?

4

1 に答える 1

0

イベントでも流星法でも同じなのは配偶者です。以下に例を示します。

Template.YourTemplateName.events({
"click #yourElement:function(event,template){
check(query,Match.Any);
 console.log("working");
 //will always log "working" 
}
});

"click #yourElement:function(event,template){
check("String",Number);
 console.log("Not working");
 //will throw an error and will not execute the log 
}
});

また、値がパターンに一致する場合に true を返す Match.test を試すこともできます。例:

   "click #yourElement:function(event,template){
        if(Match.test("String",String)){
         console.log("working");
         //will execute  
        }
       }
     });
于 2013-11-06T16:06:47.977 に答える