Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27752

How to add field with static value to mongodb find query?

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 3.2.9
    • Logging, Querying
    • None

    Description

      Can we add some custom field with static value to mongodb find query?

      I am trying to add/append API request UId to all the queries that we are making to mongodb, so that we can map requests with slow queries from mongodb logs.

      I am doing it in aggregate queries by using '$literal' in projected fields.
      My Aggregate queries looks something like :

      db.test.aggregate({
              $project: {
                  "custom_id": { $literal: "uid" } 
                  ..
              }
              ..
          })
      

      Also I can't include each field individually in projected fields and add the "custom_id" field with the static value.

      Attachments

        Activity

          People

            mark.agarunov Mark Agarunov
            sanjeev24 Sanjeev Kumar
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: