Closed thearabbit closed 9 years ago
I've updated README.md with an example. Hope that's enough!
Say we have the following schema for our Posts
collection:
new SimpleSchema({
'title': {
type: String
},
'content': {
type: String
}
});
And then we run this:
Posts.cacheCount('commentsCount', Comments, 'post_id');
Collection2 would not allow commentsCount
to be added to a post since it's not in the schema. Therefore cleaning/validation is bypassed by default. You can prevent this bypass by setting validate: true
, like this:
Posts.cacheCount('commentsCount', Comments, 'post_id', {validate: true});
But then you'd also have to add commentsCount
to the schema:
new SimpleSchema({
'title': {
type: String
},
'content': {
type: String
},
'commentsCount': {
type: Number
}
});
Very thanks, I will try.
In
Integration with SimpleSchema/Collection2
, you said...validate you must pass validate: true as an option in the methods...
. I don't understand, please example???