【发布时间】:2016-03-03 12:48:16
【问题描述】:
我想在 simpleSchema 中初始化一个字段。我想将 userId 设置为字符串字段。
这是架构:
AdsSchema = new SimpleSchema({
title: {
type: String,
label: "Title"
},
insertedBy: {
type: String,
label: "Inserted By",
autoform:{
type:"hidden"
},
autoValue: function() {
if (this.userId) {
return this.userId;
}
}
}
}
但是通过autoform插入后,插入的文档是:
{
"_id" : "Zm5TML5bwJhyN8B9F",
"title" : "test"
}
表示“insertedBy”字段的值为“null”!
我该如何解决这个问题?
【问题讨论】:
标签: mongodb meteor-accounts meteor-autoform meteor-collection2 simple-schema