我的集合和插入+更新+刪除功能正常工作,直到我將模式更改爲包含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);