Преглед на файлове

[ENH] Add index on CardId into Comments collection

fmonthel преди 8 години
родител
ревизия
d11f069b60
променени са 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 };
 
 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) => {
     Activities.insert({
       userId,