$ gt延迟加载新日期

时间:2016-03-12 09:50:47

标签: mongodb date meteor lazy-loading

我有一个像这样的数组

Sections = {
  data: [
    { _id: 0, sort: { createdAt: -1 }, filter: { expiryAt: { $gt: new Date() } } },
    { _id: 1, filter: { photosCount: { $gt: 0 } }, sort: { photosCount: -1, createdAt: -1 } }
  ],
};

我有一个函数,一旦调用执行此代码:

Ele.find(sections[i].filter || {}, {
  sort: sections[i].sort || {}, fields: { _id: 1 }, limit: 10
});

我希望过滤器中的(新Date())

{ expiryAt: { $gt: new Date() }
每次调用函数时都会计算

,而不是在存储变量Sections时计算。我试过

{ expiryAt: { $gt: function(){ return new Date() } }

但它不起作用。

我该怎么办?

由于

0 个答案:

没有答案