AndrewLeonardi
AndrewLeonardi

Reputation: 3512

Sort Mongoose data

I'm working on sorting my mongoose data. Currently what I am doing below is working perfectly:

 Rentals.find({}).sort({featured: -1})

I am now trying to add a way to not show the rentals that are "reserved."

I've been trying this but it is not working:

if (!Rentals.reserved) { 
Rentals.find({}).sort({featured: -1})

What is the correct way to do this?

Thank you!

Upvotes: 0

Views: 48

Answers (1)

Mikey
Mikey

Reputation: 6766

I'm assuming reserved is a Boolean, then just do

Rentals.find({ reserved: false }).sort({featured: -1})

Upvotes: 1

Related Questions