Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-10023

camel-mongodb - Consider sortBy header when performing findOneByQuery operation

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.17.1
    • Fix Version/s: 2.17.2
    • Component/s: camel-mongodb
    • Labels:
      None

      Description

      There is a often a requirement to fetch the min/max record from Mongo based on a particular field. Typically the operation is performed using syntax similar to:

      db.collection.find().sort({_id: -1}).limit(1)

      or

      db.collection.findOne({$query:{},$orderby:{_id:-1}})

      As implemented the findOneByQuery operation currently ignores the sortBy header. This trivial patch passes sortBy to the sort parameter of findOne(), if set.

      Helpfully, if the projection parameter is null findOne() returns all fields, so the state of fieldFilter is not checked before passing when the sortBy header has been set.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                davsclaus Claus Ibsen
                Reporter:
                kris.boutilier@gmail.com Kris Boutilier
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: