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

Suggestion for /manual/reference/operator/query/type/

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • v1.3.11
    • Affects Version/s: None
    • Component/s: manual
    • Labels:

      General: This article spends about three lines talking about the main use case of $type, and the rest talking about the corner cases of (1) looking for an array, and (2) MinKey.

      If the field holds an array, the $type operator performs the type check against the array elements and not the field.

      This is not clear to a novice: does it check that all array elements have the type, or at least one does?

      Min key 255

      There's a warning block below the table that MinKey needs to be queried as -1, not 255. Consider adding a note to the table.

      Where is the value 255 used at all?

      MinKey and MaxKey compare less than and greater than all other possible BSON element values, respectively, and exist primarily for internal use.

      Fine, but why is half the article discussing how to manipulate them?

      Storing values of the different types in the same field in a collection is strongly discouraged.

      (1) Grammar: "of different types", not "of the different types".

      (2) It is not clear what is strongly discouraged. Do you mean that it's bad to have two documents whose x field has different types, like this:

       {_id:1, x: 1} {_id:2, x: "bad?"} 

      Or do you mean that it's bad to have one document whose x field is an array containing different-typed elements, like this:

       {_id:3, x: [3, "different bad!"]} 

      Word this clearly and give an example.

      Also, indicating why it's bad would be helpful too.

            Assignee:
            andrew.aldridge@mongodb.com Andrew Aldridge
            Reporter:
            bard.bloom@10gen.com bard.bloom@10gen.com
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              9 years, 33 weeks, 1 day ago