Querying with near operator

default discord avatar
wmcmorrow212 months ago
3

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
    notchr12 months ago

    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
    wmcmorrow212 months ago

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

  • default discord avatar
    notchr12 months ago

    Of course!

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.