search

Home  >  Q&A  >  body text

sort - mongodb 结果集默认顺序标准

collection有多个文档,如果查询结果没有进行sort排序,那么find()的结果集的默认顺序是以什么为标准的?

怪我咯怪我咯2896 days ago745

reply all(2)I'll reply

  • 黄舟

    黄舟2017-04-22 09:02:24

    Basically the order in the file (so it is often the order of insert).

    To be cautious, you can think of it as disorder. If you need a specific order, you still have to use sort.

    Reference:

    http://docs.mongodb.org/manual/reference/glossary/#term-natural-order

    reply
    0
  • ringa_lee

    ringa_lee2017-04-22 09:02:24

    When mongodb inserts data, it will add the "_id" attribute by default and create an index with it. So it's the order of insertion.

    reply
    0
  • Cancelreply