Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. This is the easiest way you can:
  2.  
  3. var thisDate = ISODate("2016-01-07T00:00:00Z");
  4.  
  5. Model.find({
  6. startDate: {
  7. '$lte': thisDate
  8. },
  9. endDate: {
  10. '$gte': thisDate
  11. }
  12. });
  13.  
  14. It will return all docs (in array) in which `startDate` greater than or equals to `thisDate` and `endDate` less than or equals to `thisDate`
  15.  
  16. For `counts` use `.length()` on your received collection which is array so .length() will return you count easily..
  17.  
  18. Hope this helps.
  19.  
  20. Cheers,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement