瀏覽代碼

Merge pull request #18 from fmonthel/devel

[ENH] Add index on CardId into Comments collection
Lauri Ojansivu 8 年之前
父節點
當前提交
693f615136
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      models/cardComments.js

+ 6 - 0
models/cardComments.js

@@ -57,6 +57,12 @@ CardComments.helpers({
 CardComments.hookOptions.after.update = { fetchPrevious: false };
 CardComments.hookOptions.after.update = { fetchPrevious: false };
 
 
 if (Meteor.isServer) {
 if (Meteor.isServer) {
+  // Comments are often fetched within a card, so we create an index to make these
+  // queries more efficient.
+  Meteor.startup(() => {
+    CardComments._collection._ensureIndex({ cardId: 1, createdAt: -1 });
+  });
+
   CardComments.after.insert((userId, doc) => {
   CardComments.after.insert((userId, doc) => {
     Activities.insert({
     Activities.insert({
       userId,
       userId,