1
我想初始化simpleSchema中的一个字段。我想将userId设置为一个字符串字段。将meteor.userId插入到mongoDB中
这里是架构:
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;
}
}
}
}
而是通过自动窗体插入后,插入的文件是:
{
"_id" : "Zm5TML5bwJhyN8B9F",
"title" : "test"
}
它意味着 “insertedBy” 字段 “空” 值!
我该如何解决这个问题?
我使用Meteor.userId()代替this.userId,并解决了问题。谢谢 – Roohollah