0

I am trying to figure out how I can pull records from a mongo database using Jongo that will check the date that is on the object in the db and will only return an object with the data from, in my case, the last three most current dates. I'm using LocalDate to set the date on the object.

So that's the problem, what I'm doing is I have an angularjs web ui that interfaces with a java backend and I'm trying to scale down my scope, because the current way I'm displaying data is not feasibly scalable. So I want to limit the response I receive to the last 3 objects created instead of all of the objects. And I'm to the point where I need to do a check on the date but I can't seem to find a reasonable solution. isAfter() and isBefore() was where I started my initial effort, but I can't guarantee the dates in any way so I don't know where to set my constraints.

The code I'm working on doesn't really matter, I'm just more interested in how I can do the check in general.

Thanks in advance for any help, if any at all, can be offered!

Kristaphonie
  • 99
  • 2
  • 11
  • 1
    Is there something like MIN(field) in mongodb? – MaxZoom Jun 19 '15 at 18:30
  • Hey what do you know there is. It has a $min function that constrains the mongodb find() results. Thanks! I'll give that a try and if that doesn't work I'll come back. – Kristaphonie Jun 19 '15 at 18:55
  • 1
    Also here's a link to the documentation for anyone else who might be looking http://docs.mongodb.org/manual/reference/operator/meta/min/ . – Kristaphonie Jun 19 '15 at 18:56
  • I did not know if it exists in mongodb, but every respected DB should has something like that.I am glad you have found it. – MaxZoom Jun 19 '15 at 19:17

0 Answers0