'Mongodb new data insert in top
Usually mongodb saves previous data on top. Can we save data as new at the top?
Mean i want to insert my new data on 0 no index every time and pervious data will go down as Array.unshift() method...
Solution 1:[1]
Not sure if I got you right.
Within a document: This could be helpful $position
Within a collection: You could just sort by _id descending when accessing the data to get new documents first.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nonnial |
