How do I sort new items by newest?

zyzzbruh

I have this nodeJS code but whenever I post my data, the newest data is added on the end instead of start. I tried adding Crud.find().sort('_id', -1).exec((err, data) => but it still doesn't work.

app.get('/v2/posts', (req,res) => {
    Crud.find((err, data)=> {
        if (err) {
            res.status(500).send(err)
        } else {
            res.status(200).send(data)
        }
    })
});
Mohit Gupta

try-

Crud.find().sort({$natural:-1})

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I sort list items based on numbers at the end of text inside?

Add new column based on a list and sort date by newest

In Python, given a dictionary with lists in the values, how do I sort the dictionary based on the amount of items in that list?

How do I get the newest updates to Cloud Build?

How do I only display the newest document?

How do I detect the newest row in a specific column?

How do I get the newest tag with Azure devops Rest Api?

How do I sort in numerical order, the items in a to-many relationship?

How do I sort items by array?

How do I sort or move DONE items in org-mode?

How do I use trackPageView with Google Analytics (newest version)?

How can I sort the items in a ListView?

How do I concatenate all the files in a given directory in order of date, where I want the newest file on top?

How do I change folder timestamps recursively to the newest file?

How do I get the MBR Partition table with newest fdisk?

How do I create a new/create action for items?

How do I update Firefox to the newest version?

How do I get newest version of adobe flashplayer?

How do I sort a list by newest date?

How do I place new items at the top of a recyclerView?

How to get new items in a scrollable flexbox container to appear newest lowermost (Fiddle included)

How do I get the newest lowlatency-kernel on 18.04 LTS?

How to sort a column from newest to oldest?

How can I retrieve all data and label the one that are the newest as the new data?

How do I sort the list or other items using JS?

How do I sort in numerical order, the items in a to-many relationship?

How do I sort in the front end with javascript an array of items based on other fields inside the item

How sort this array of items by date in desc order (I used loadash sortBy but it returns oldest first while I need newest first)?

How to sort String List by newest in dart

TOP Ranking

HotTag

Archive