import { query } from "./_generated/server";
import schema from "./schema.ts";
export const get = query({
args: {
slug: schema.tables.properties.validator.fields.slug,
},
handler: async (ctx, args) => {
const property = await ctx.db.query("properties").withIndex(
"by_slug",
(q) => q.eq("slug", args.slug),
).collect();
return property;
},
});
const properties = useQuery(api.getPropertyBySlug, { slug: property });
Diagnostics:
- Argument of type '{ get: FunctionReference<"query", "public", { slug: string; }, { _id: Id<"properties">; _creationTime: number; property_title?: string | undefined; description?: string | undefined; min_rental_duration?: string | undefined; ... 26 more ...; price: number; }[], string | undefined>; }' is not assignable to parameter of type 'FunctionReference<"query">'.
Type '{ get: FunctionReference<"query", "public", { slug: string; }, { _id: Id<"properties">; _creationTime: number; property_title?: string | undefined; description?: string | undefined; min_rental_duration?: string | undefined; ... 26 more ...; price: number; }[], string | undefined>; }' is missing the following properties from type 'FunctionReference<"query">': _type, _visibility, _args, _returnType, _componentPath [2345]