【问题标题】:SimpleSchema.clean message in console控制台中的 SimpleSchema.clean 消息
【发布时间】:2016-07-06 20:45:20
【问题描述】:

我在同时显示一组更新表单时收到此控制台消息。据我所知,我已经正确地遵循了 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);

【问题讨论】:

  • 请显示StudentHistory 集合的架构代码。
  • 我已经更新了上面的代码

标签: meteor meteor-autoform meteor-collection2


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2012-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-01
    • 2017-10-23
    相关资源
    最近更新 更多