diff options
Diffstat (limited to 'models/announcements.js')
-rw-r--r-- | models/announcements.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/models/announcements.js b/models/announcements.js new file mode 100644 index 00000000..2cb1e1b7 --- /dev/null +++ b/models/announcements.js @@ -0,0 +1,36 @@ +Announcements = new Mongo.Collection('announcements'); + +Announcements.attachSchema(new SimpleSchema({ + enabled: { + type: Boolean, + defaultValue: false, + }, + title: { + type: String, + optional: true, + }, + body: { + type: String, + optional: true, + }, + sort: { + type: Number, + decimal: true, + }, +})); + +Announcements.allow({ + update(userId) { + const user = Users.findOne(userId); + return user && user.isAdmin; + }, +}); + +if (Meteor.isServer) { + Meteor.startup(() => { + const announcements = Announcements.findOne({}); + if(!announcements){ + Announcements.insert({enabled: false, sort: 0}); + } + }); +} |