I\'m trying to insert different items to a MongoDB collection, but I want to the item to be inserted at the top of the array so when retrieving the collection items I can get th
You should just write a query for the data that you want. The $orderby operator will sort the data any way you like.
collection.find({ $query: {}, $orderby: { postid: -1 } });
If you really just need the last item, you could limit the query to one result as well. Note that this version uses the sort function as well.
collection.find().sort({ postid: -1 }).limit(1);