2017-05-16 11 views
0

Stringと変更されたイベントを作成しようとしました。NetworkAppコレクションにstatusと表示されています。シンプルスキーマで更新が無視される

イベント:

Template.app_detail.events({ 
    'click .accept': function (e, t) { 
    console.log("Accept"); 
     NetworkApp.update(this._id, {$set:{ 
     status: "Accepted" 
     }}); 
    }, 
    'click .reject': function (e, t) { 
    console.log("Reject"); 
    NetworkApp.update(this._id, {$set:{ 
     status: "Rejected" 
    }}); 
    } 
}) 

これは、アプリケーションが変更された最後の時間ではなく、ステータスを更新します。コンソールにエラーは表示されませんが、ログにAcceptedまたはRejectedが記録され、コードがdbに接続でき、ヘルパーがボタンによってトリガーされるようになります。すべてのヘルプは高く評価され〜


簡単なスキーマ:!

NetworkAppSchema = new SimpleSchema({ 
    ign: { 
    type: String, 
    label: "IGN" 
    }, 
    discordName: { 
    type: String, 
    label: "Discord Name" 
    }, 
    memberlength: { 
    type: String, 
    label: "How long have you been a member at Digital Hazards?" 
    }, 
    languageKnown: { 
    type: String, 
    label: "What languages do you know?", 
    autoform: { 
     type: 'textarea' 
    } 
    }, 
    whyyou: { 
    type: String, 
    label: "Why do you want to join the Network staff?", 
    autoform: { 
     type: 'textarea' 
    } 
    }, 
    applicant: { 
    type: String, 
    label: "Applicant", 
    autoValue: function() { 
     return Meteor.userId(); 
    }, 
    autoform: { 
     type: "hidden" 
    } 
    }, 
    createdAt: { 
    type: Date, 
    label: "Applied At", 
    autoValue: function() { 
     return new Date(); 
    }, 
    autoform: { 
     type: "hidden" 
    } 
    }, 
    status: { 
    type: String, 
    label: "Status", 
    autoValue: function() { 
     return "Pending"; 
    }, 
    autoform: { 
     type: "hidden", 
    } 
    } 


}); 
+1

は、あなたが実際のドキュメントに 'this._id'ポイントいることが確認されたことがありますか? –

+0

'createdAt'フィールドはイベントをトリガーするたびに更新され、コレクションに影響します –

+0

それでシンプルスキーマを使用していますか?スキーマコードを共有できますか? –

答えて

1

autoValueinitial valueを意味するものではありません:あなたのautoValue機能は、すべての時間を実行しています。

createdAtについては、例えば、あなたが持っている必要があります。

createdAt: { 
    type: Date, 
    denyUpdate: true, 
    autoValue() { 
    if (this.isInsert) return new Date(); 
    }, 
}, 

これは今までの挿入後に変更createdAtを避けることができます。ステータスの同様

status: { 
    type: String, 
    label: "Status", 
    autoValue() { 
    if (this.isInsert) return "Pending"; 
    }, 
    autoform: { 
    type: "hidden", 
    } 
} 
+0

に追加しました。これはなぜthis.insertが1つで、もうthis.isInsertがもう1つですか? –

+0

申し訳ありませんがタイプミスが修正されました。 –

+0

何かをインポートする必要がありますか?私はそれを行うと、更新プログラムは動作しますが、元の挿入はしません。バグを修正して別のバグを作成します。 –

関連する問題