Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Near operator isn't ordering items

default discord avatar
wmcmorrow2last year

I'm using the near operator to query a list of locations based on their proximity from me. The items seem to be returned in random order instead of the nearest first as defined in the documentation.



const lng = myProfile.location[0]


const lat = myProfile.location[1]



const query = {


location: {


near: [


lng,


lat,


10000,


]


},


and: [


{


subcategories: {


equals: subcategory,


}


},


]


};


const stringifiedQuery = qs.stringify(


{


where: query,


},


{ addQueryPrefix: true },


);



I'm using Payload 1.9.1. Could this be a bug?



Ahh looks like it's a known issue



https://github.com/payloadcms/payload/issues/2848

Upgrading to the latest version fixed the issue 👍

    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get dedicated engineering support directly from the Payload team.