Vulcan/packages/nova-newsletter/lib/collection.js
2016-02-24 10:27:46 +09:00

45 lines
No EOL
783 B
JavaScript

Telescope.newsletter = {};
var campaignSchema = new SimpleSchema({
_id: {
type: String,
optional: true
},
createdAt: {
type: Date,
optional: true
},
sentAt: {
type: String,
optional: true
},
status: {
type: String,
optional: true
},
posts: {
type: [String],
optional: true
},
webHits: {
type: Number,
optional: true
},
});
Campaigns = new Meteor.Collection("campaigns", {
schema: campaignSchema
});
// create new "campaign" view for all posts from the past X days that haven't been scheduled yet
Posts.views.add("campaign", function (terms) {
return {
find: {
scheduledAt: {$exists: false},
postedAt: {
$gte: terms.after
}
},
options: {sort: {baseScore: -1}}
};
});