-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
my current code is
export const searchBookswithLocation = query({
args: {
searchTerm: v.string(),
latitude: v.number(),
longitude: v.number(),
},
handler: async (ctx, args) => {
const maxResults = 16;
const maxDistance = 10000;
const result = await geospatial.queryNearest(
ctx,
{ latitude: args.latitude, longitude: args.longitude },
maxResults,
maxDistance,
)
;
return result;
},
});
would like to use this with a search index or even just filter it down, have something like this
export const searchBooks = query({
args: {
searchTerm: v.string(),
},
handler: async (ctx, args) => {
const maxDistanceMeter = 10;
const books = await ctx.db
.query("books")
.withSearchIndex("bookSearch", (q) =>
q.search("searchString", args.searchTerm).eq("status", "Available"),
)
.take(10);
return books;
},
});
Metadata
Metadata
Assignees
Labels
No labels