1
我尝试在autoform插入到另一个集合(Meteor.users)后插入到用户配置文件数组中。流星Autoform,集合钩子 - 集合插入后如何插入用户配置文件数组?
我的简单模式阵列设置这样的 -
listings: {
type: [String],
optional: true
},
"listings.$.id": {
type: String,
optional: true
}
(轮廓模式中),这是我收集挂机方法应该上市插入后插入。
//Add listing to user collection on submit
Listings.after.insert(function(userId, doc) {
console.log("STUFF");
Meteor.users.update({_id : userId},
{
$push :
{
'profile.listings.$.id' : this._id
}
}
在我看来,这应该工作。表单正确插入没有集合挂钩,但现在当我提交表单,我得到这个错误在我的JS控制台:
错误:筛选出不在模式中的键后,您的修改器现在为空(...)
console.log(“stuff”)触发器,我在控制台中发现错误之前。
任何人有任何想法如何做到这一点?
编辑 - 固定的几件事情通过它切换到:
Listings.after.insert(function(userId, doc) {
console.log("STUFF" + userId + ' ' + this._id);
Meteor.users.update({_id: userId },
{
$set :
{
"profile.listings.$.id" : this._id
}
}
) });
现在我不能插入到数组中,因为$操作符。
在短短的一秒钟内就能拍出这张照片,非常感谢。 – bolle
你是男人!非常感谢,我也复制了我如何使用个人资料图片模式。 – bolle