check eq and lt for multiple fields

I have this index defined in my schema:

    .index("coord_idx", ["lon", "lat"]),


Now I want to check if something is in a bounding box by using this index:

const citiesInBoundingBox = await ctx.db
      .query("search")
      .withIndex("coord_idx", (q) =>
        q
          .gt("lon", args.coord.lon - 0.1)
          .lt("lon", args.coord.lon + 0.1)
          .gt("lat", args.coord.lat - 0.1)
          .lt("lat", args.coord.lat + 0.1),
      );


Unfortunately, this is not possible because you can only chain one gt and one lt operator on this.

DISCLAIMER, HAS NOTHING TODO WITH MY FEATURE REQUEST: (working on the geohashes (maybe with the article I will fully understand or know how to implement it) btw. but thought this would be a much quicker solution to get it running.
Was this page helpful?