我想添加一个对象到一个对象数组,这是一个集合项中的一个键,下面的代码,但我得到一个奇怪的响应“插入失败:错误:标题是必需的“。我在流星上使用简单的模式/ autoform。插入失败:错误:标题是必需的
有没有人遇到过这个(并有一个解决方案)?
Template.dashboard.events({
'click .requestinvite'(e,t) {
Posts.insert({ _id : $(e.currentTarget).attr('_id')},
{$push: { invitesRequested : {username : Meteor.userId()} }}
);
}
});
这里是CoffeeScript的相关简单的模式
Schemas.Posts = new SimpleSchema
title:
type:String
max: 60
optional: true
content:
type: String
optional: false
autoform:
rows: 5
createdAt:
type: Date
autoValue: ->
if this.isInsert
new Date()
updatedAt:
type:Date
optional:true
autoValue: ->
if this.isUpdate
new Date()
invitesRequested:
type: [Object]
optional: true
defaultValue: []
owner:
type: String
regEx: SimpleSchema.RegEx.Id
autoValue: ->
if this.isInsert
Meteor.userId()
autoform:
options: ->
_.map Meteor.users.find().fetch(), (user)->
label: user.emails[0].address
value: user._id
你的简单模式必须有一个标题是必需的 – Mikkel
是的,好像简单模式阻止插入,你需要允许标题。 – Deano
请在这里发布您的SimpleSchema。提供足够的细节,以免我们浪费时间在你的问题上。 –