Skip to content

Commit

Permalink
Step 12.31: Add hook for removing unused messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and DAB0mB committed Mar 23, 2017
1 parent 3dbef0e commit c28e7d6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/server/collections/chats.ts
@@ -1,4 +1,10 @@
import { MongoObservable } from 'meteor-rxjs';
import { Chat } from '../models';
import { Messages } from './messages';

export const Chats = new MongoObservable.Collection<Chat>('chats');

// Dispose unused messages
Chats.collection.after.remove(function (userId, doc) {
Messages.collection.remove({ chatId: doc._id });
});

0 comments on commit c28e7d6

Please sign in to comment.