0

Actually I am doing project using mongodb. after I update record and find all records, it change the document position. so how I avoid that problem.

user1784592
  • 129
  • 1
  • 3
  • 11

1 Answers1

1

The 'natural' (i.e. unsorted) order of docs in a collection can change as updates are made so if you want a specific order to the docs returned from a query you need to include a sort object in your query.

JohnnyHK
  • 305,182
  • 66
  • 621
  • 471