2016-10-20 15 views
0

クライアントからレコードを更新しようとしていますが、エラーが発生し続けます。 data = {}オブジェクトにすべてを入れて、それを私のMeteor.callメソッドに渡しましたが、まだそれを動作させることができませんでした。修飾子が無効です。修飾子はオブジェクトである必要があります。エラー

ブラウザerrorClass {error: 500, reason: "Internal server error", details: undefined, message: "Internal server error [500]", errorType: "Meteor.Error"}

サーバーException while invoking method 'updateComment' Error: Invalid modifier. Modifier must be an object.

私はそれは私が私のupdateCommentメソッドを呼び出していますどのように関係している知っています。誰かが私を正しい方向に向ける気がしますか?

ありがとうございます。

現在のコード:

コメント/ methods.js

updateComment: function (commentId, commentContent, userId, fritkotId) { 
    // check(commentId, String); 
    // check(commentContent, String); 
    // check(userId, String); 
    // check(firtkotId, String); 
    Comments.update({ 
      _id: commentId, 
      body: commentContent, 
      author: userId, 
      fritkotId: fritkotId, 
      modifiedAt: new Date() 
     }); 
}.... 

editComment.js

import './editComment.tpl.jade' 

// Events 
Template.editComment.events({ 
'click .form-save': (e) => { 

    e.preventDefault(); 

    let data = {}; 

    let commentContent = $('.update-comment').val(); 

    let fritkotId = Fritkots.findOne({})._id; 
    let commentId = Comments.findOne({})._id; 
    let userId = Meteor.userId(); 

    // data.commentId = commentId; 
    // data.commentContent = commentContent; 
    // data.userId = userId; 
    // data.fritkotId = fritkotId; 

    console.log(` This is the commentId: ${commentId}, userId: ${userId}, fritkotId: ${fritkotId}`); 

    Meteor.call('updateComment', commentId, commentContent, userId, fritkotId, function(error) { 
     if (!error) { 
      console.log('comment updated'); 
     } else { 
      console.log(error); 
      console.log('unable to update comment'); 
     } 
    }) 

    console.log(`The comment was updated to this ${commentContent}`); 

    console.log('I was clicked for save'); 

    // Session.set('editCommentId', false); 
    Session.set('editCommentId', null); 
}, 
.... 

コレクション/ comments.js

Comments = new Mongo.Collection('comments') 

// Permissions 
Comments.allow({ 
    insert:() => false, 
    // update: (userId, doc) => { return !! userId; }, 
    update:() => false, 
    remove:() => false 
}); 

Comments.deny({ 
    insert:() => true, 
    update:() => true, 
    // update: (userId, doc) => { return !! userId; }, 
    remove:() => true 
}); 

答えて

1

コメントを識別する方法を見つけて、変更したい部分を渡す必要があります。 .update()の使用には間違いなく問題があります(ドキュメントを確認してください)。問題を解決し

Comments.update(id, {$set: {key: value}}) 

またはこの

Comments.update(id, {$set: {key: value}}) 
+0

感謝:

は、私はあなたがこのような何かをしたいと考えています。 – intercoder

関連する問題