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

Include/Exclude Projection Syntax

    XMLWordPrintable

    Details

      Description

      Hello!

      I have a proposition for impovements in MongoDB. I want to tell about
      db.collection.find() improvements.

      Currently syntax of query with projection is like:
      db.things.find( { param : "value" } , { field1 : 1, field2: 1 } )

      Why don't change the syntax to
      db.things.find( { param : "value" } , { (include/exclude): [fields]} )

      I'll try to give you examples that you could understand what I mean:

      db.things.find( { x : 4 } , {include:[_id, j]} )
      db.things.find( { x : 4 } , {exclude:[_id, x]} )

      In such syntax we can use _id field as a usual field, an it is not
      included to projection implicitly. Another advantage is that we can
      just pass array of fields instead of giving 0 or 1 values to field
      names.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: