我的集合和插入+更新+删除功能正常工作,直到我将模式更改为包含upVoters!没有任何功能似乎工作,虽然他们在添加之前工作正常。我使用aldeed简单模式,我没有得到任何错误。问题在于upVoters的默认值,因为当我评论默认值时,所有事情都可以顺利进行。不过,我需要跟踪每个upVoter,让他们投票一次。更改模式后无法插入或更新 - 流星JS + Mongo
任何想法?提前致谢!
import SimpleSchema from 'simpl-schema';
SimpleSchema.extendOptions(['autoform']);
Ideas = new Mongo.Collection('ideas');
Ideas.allow({
insert: function(userId, doc) {
return !!userId;
},
update: function(userId, doc) {
return !!userId;
}
});
IdeaSchema = new SimpleSchema({
title: {
type: String,
label: "Title"
},
category: {
type: String,
label: "Category"
},
owner: {
type: String,
label: "Owner",
autoValue: function() {
return this.userId
},
autoform: {
type: "hidden"
}
},
createdAt: {
type: Date,
label: "Created At",
autoValue: function() {
return new Date()
},
autoform: {
type: "hidden"
}
},
upVoters: {
type: Array,
label: 'Up Voters',
defaultValue: [this.userId],
optional: true,
autoform: {
type: "hidden"
}
},
'upVoters.$': {
type: String
},
});
Meteor.methods({
deleteIdea: function(id) {
Ideas.remove(id);
}
});
Ideas.attachSchema(IdeaSchema);