import SimpleSchema from "simpl-schema";

Permissions = new Mongo.Collection("permissions");

const PermissionsSchema = new SimpleSchema({
  residentId: {
    type: String
  },
  groupId: {
    type: String
  }
});

Permissions.attachSchema(PermissionsSchema);

Meteor.startup(function() {
  if (Meteor.isServer) {
    // Make sure residentId field is indexed for performance
    Permissions._ensureIndex({ residentId: 1 });

    // Make sure groupId field is indexed for performance
    Permissions._ensureIndex({ groupId: 1 });
  }
});

@@ -33,16 +33,75 @@
 schema%22;
+%0Aimport UserEventLog from %22/both/collections/userEventLog%22;
 %0A%0APermis
@@ -582,16 +582,625 @@
 : 1 %7D);%0A  %7D%0A%7D);%0A
+%0APermissions.after.insert(function(userId, permission) %7B%0A  // Add event log%0A  UserEventLog.insert(%7B%0A    userId,%0A    action: %22insert%22,%0A    entityType: %22permission%22,%0A    entityId: permission._id%0A  %7D);%0A%7D);%0A%0APermissions.after.update(function(userId, permission) %7B%0A  // Add event log%0A  UserEventLog.insert(%7B%0A    userId,%0A    action: %22update%22,%0A    entityType: %22permission%22,%0A    entityId: permission._id%0A  %7D);%0A%7D);%0A%0APermissions.after.remove(function(userId, permission) %7B%0A  // Add event log%0A  UserEventLog.insert(%7B%0A    userId,%0A    action: %22remove%22,%0A    entityType: %22permission%22,%0A    entityId: permission._id%0A  %7D);%0A%7D);%0A

Add event logging