控制台中的SimpleSchema.clean消息

时间:2016-07-06 02:55:08

标签: meteor meteor-autoform meteor-collection2

我在一起显示一组更新表单时收到此控制台消息。据我所知,我已经正确地遵循了Autoform示例。谁能告诉我我做错了什么?

SimpleSchema.clean:过滤掉会影响密钥" _id"的值,这是模式不允许的

路径:form.html

{{#each student}}
    {{#autoForm id=makeUniqueID type="update" collection="StudentHistory" doc=this}}
    <div class="panel panel-default edit-profile-margin-pannel">
        <div class="panel-body">
            {{> afQuickField name='class'}}                                     
        </div>                                          
    </div>  
    {{/autoForm}}
{{/each}}

路径:form.js

Template.form.helpers({
    student: function() {
        return StudentHistory.find({});
    },
    makeUniqueID: function () {
        return "update-each-" + this._id;
    }
});

路径:Schema.js

StudentHistory = new Mongo.Collection("studentHistory");

StudentHistory.allow({
    insert: function(userId, doc) {
        return !!userId;
    },
    update: function(userId, doc) {
        return !!userId;
    },
    remove: function(userId, doc) {
        return !!userId;
    }
});


var Schemas = {};

Schemas.StudentHistory = new SimpleSchema({
    studentUserId: {
        type: String,
        autoValue: function() { 
            return this.userId; 
        },
        autoform: {
            type: "hidden"
        }
    },
    class: {
        type: String,  
        optional: false    
    }
});

StudentHistory.attachSchema(Schemas.StudentHistory);

1 个答案:

答案 0 :(得分:0)

我的错误出现在模板助手中。当我添加下面的代码时,消息消失。

Template.form.helpers({
    student: function() {
        return StudentHistory.find({"studentUserId": Meteor.userId()});
    }
});