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.

Querying with near operator

default discord avatar
wmcmorrow2last year
4

Does anyone have an example of how you query documents with the near operator? I'm not really clear if you're supposed to use a string or array or something else.

  • default discord avatar
    notchrlast year

    Good morning @wmcmorrow2 !



    I'm looking for an example, but in the meantime, check out the near tests



    https://github.com/payloadcms/payload/blob/master/test/collections-rest/int.spec.ts#L800


    For instance, one test uses..



                query: {
                  // querying large enough range to include all docs
                  point: { near: '0, 0, 100000, 0' },
                },


    So it looks like it can be a point / range in CSV format?

  • default discord avatar
    wmcmorrow2last year

    @notchris Ahh yes, it's a string! The error was due to using longitude twice. Many thanks

  • default discord avatar
    notchrlast year

    Of course!

  • default discord avatar
    .muhad4 months ago

    Adding this one

    how to query the near data

    in docs help lots for starters

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.