How does mongodb guarantee the compound index order with javascript un-ordered object literal creation?

XMLWordPrintableJSON

    • Type: Question
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Such as db.products.createIndex(

      { "item": 1, "stock": 1 }

      )
      Quoted from https://docs.mongodb.com/manual/tutorial/sort-results-with-indexes/
      You can specify a sort on all the keys of the index or on a subset; however, the sort keys must be listed in the same order as they appear in the index.
      As there is no order in javascript object, how could mongodb get an order from that?

            Assignee:
            Unassigned
            Reporter:
            Roben
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: