summaryrefslogtreecommitdiffstats
path: root/models/rules.js
blob: df0ccceaa0c5046b5382d5b8e91ee09edc1c9736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Rules = new Mongo.Collection('rules');

Rules.attachSchema(new SimpleSchema({
  title: {
    type: String,
    optional: true,
  },
  triggerId: {
    type: String,
    optional: true,
  },
  actionId: {
    type: String,
    optional: true,
  },
}));

Rules.mutations({
  rename(description) {
    return { $set: { description } };
  },
});




Rules.allow({
    update: function () {
    // add custom authentication code here
    return true;
  },
    remove: function () {
    // add custom authentication code here
    return true;
  },
    insert: function () {
    // add custom authentication code here
    return true;
  },
});




if (Meteor.isServer) {
  Meteor.startup(() => {
    const rules = Rules.findOne({});
    if(!rules){
      Rules.insert({title: "regola1", description: "bella"});
      Rules.insert({title: "regola2", description: "bella2"});
    }
  });
}