Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-9024

$unwind of non-array should be allowed

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • None
    • None
    • Server
    • None
    • true

    Description

      This would effectively just output the existing field.

      > db.reg.find()
      { "_id" : 1, "text" : "foo" }
      { "_id" : 2, "text" : "bar" }
      { "_id" : 3, "text" : "Bar" }
      { "_id" : 4, "text" : [ "bar", "foo" ] }
      >db.reg.aggregate({$match:{text:/ba/i}}, {$unwind:"$text"})
      ...
      	"errmsg" : "exception: $unwind:  value at end of field path must be an array",
      	"code" : 15978,
      	"ok" : 0

      This will be important for collections where some document fields may be arrays, but some may not.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              emily.hall Emily Hall
              Kay Kim Kay Kim (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                4 years, 29 weeks, 1 day ago