meteor - Select the parameters MongoDB MeteorJS -


i want return posts created today , sort them date { sort: { createdat: -1 }}

code have :

<template name="m_table_time">   <div class="container">         <h1 class="table_date">today</h1>         {{> m_table posts=today}}   </div> </template>  template.m_table_time.helpers({   today: function() {     var today = moment().todate();     var daystart  = moment().startof('day').todate();     return posts.find({},{ sort: { createdat: -1 }},{$gte: daystart, $lte: today  }); // doesnt work   },  <template name="m_table">           <table class="main-table table">               {{#each posts}}                 {{> m_jobs}}               {{/each}}           </table> </template> 

also tried this

return posts.find({},{ sort: { createdat: -1 }},{bigpost:true}); // doesnt work 

anybody ?

the first argument find selector, , that's date rules need go:

var selector = {createdat: {$gte: daystart, $lte: today}}; return posts.find(selector, {sort: {createdat: -1}}); 

also see this question.


Comments