Coffee11
Coffee11
CCConvex Community
Created by Coffee11 on 6/22/2024 in #support-community
Image compression integration
Will this work with react-native as well?
11 replies
CCConvex Community
Created by Coffee11 on 6/21/2024 in #support-community
Dynamic query
Problem solve ❤️
8 replies
CCConvex Community
Created by mwarger on 3/22/2024 in #support-community
How to filter based on a field while also using search index?
but still can be extend by filter after the withSearchIndex
6 replies
CCConvex Community
Created by mwarger on 3/22/2024 in #support-community
How to filter based on a field while also using search index?
the problem with this is filtering with numbers q.search() doesn't have gtq or lte function
6 replies
CCConvex Community
Created by Coffee11 on 6/21/2024 in #support-community
Dynamic query
Error
Type 'OrderedQuery<{ document: { _id: Id<"property_listings">; _creationTime: number; pricePerSqm?: number | undefined; buildingName?: string | undefined; pricePerSqmFormatted?: string | undefined; ... 22 more ...; description: string; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { ...; }; searchIndexes: { ...;...' is missing the following properties from type 'QueryInitializer<{ document: { _id: Id<"property_listings">; _creationTime: number; pricePerSqm?: number | undefined; buildingName?: string | undefined; pricePerSqmFormatted?: string | undefined; ... 22 more ...; description: string; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { ...; }; searchIndexes: { ...': fullTableScan, withIndex, withSearchIndex, order
Type 'OrderedQuery<{ document: { _id: Id<"property_listings">; _creationTime: number; pricePerSqm?: number | undefined; buildingName?: string | undefined; pricePerSqmFormatted?: string | undefined; ... 22 more ...; description: string; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { ...; }; searchIndexes: { ...;...' is missing the following properties from type 'QueryInitializer<{ document: { _id: Id<"property_listings">; _creationTime: number; pricePerSqm?: number | undefined; buildingName?: string | undefined; pricePerSqmFormatted?: string | undefined; ... 22 more ...; description: string; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { ...; }; searchIndexes: { ...': fullTableScan, withIndex, withSearchIndex, order
8 replies
CCConvex Community
Created by Coffee11 on 6/21/2024 in #support-community
Dynamic query
if (propertyType) {
const fieldToFilter =
propertyType.name === "Condominium" ? "floorSize" : "lotSize";

if (args?.minSqm !== undefined && args.minSqm >= 0) {
baseQuery = baseQuery.filter((q) =>
q.gte(q.field(fieldToFilter), Number(args.minSqm))
);
}

if (args?.maxSqm !== undefined && args.maxSqm >= 0) {
const maxSqmLimit = 999_999;
baseQuery = baseQuery.filter((q) =>
q.lte(q.field(fieldToFilter), Number(args.maxSqm || maxSqmLimit))
);
}
}

if (args?.search) {
baseQuery = baseQuery.withSearchIndex("search_descripton", (q) =>
q.search("description", args.search!)
);
}

const results = await baseQuery.order("desc").paginate(args.paginationOpts);

const updatedPage = await Promise.all(
results.page.map(async (propertyListing) => ({
...propertyListing,
listingType: (await ctx.db.get(propertyListing.listingType))?.name,
propertyType: (await ctx.db.get(propertyListing.propertyType))?.name,
favorite: (await favorite(propertyListing._id, user._id)) !== null,
}))
);

return {
...results,
page: updatedPage,
};
if (propertyType) {
const fieldToFilter =
propertyType.name === "Condominium" ? "floorSize" : "lotSize";

if (args?.minSqm !== undefined && args.minSqm >= 0) {
baseQuery = baseQuery.filter((q) =>
q.gte(q.field(fieldToFilter), Number(args.minSqm))
);
}

if (args?.maxSqm !== undefined && args.maxSqm >= 0) {
const maxSqmLimit = 999_999;
baseQuery = baseQuery.filter((q) =>
q.lte(q.field(fieldToFilter), Number(args.maxSqm || maxSqmLimit))
);
}
}

if (args?.search) {
baseQuery = baseQuery.withSearchIndex("search_descripton", (q) =>
q.search("description", args.search!)
);
}

const results = await baseQuery.order("desc").paginate(args.paginationOpts);

const updatedPage = await Promise.all(
results.page.map(async (propertyListing) => ({
...propertyListing,
listingType: (await ctx.db.get(propertyListing.listingType))?.name,
propertyType: (await ctx.db.get(propertyListing.propertyType))?.name,
favorite: (await favorite(propertyListing._id, user._id)) !== null,
}))
);

return {
...results,
page: updatedPage,
};
8 replies
CCConvex Community
Created by Coffee11 on 6/21/2024 in #support-community
Dynamic query
this is the full code any idea or docs I can check how can I mix dynamic filters with full text search?
8 replies
CCConvex Community
Created by Coffee11 on 6/21/2024 in #support-community
Dynamic query
it was the ...baseQuery before
return {
...results,
page: updatedPage,
};
return {
...results,
page: updatedPage,
};
8 replies
CCConvex Community
Created by Coffee11 on 6/21/2024 in #support-community
Dynamic query
Solve the issue now sorry it was the return
8 replies
CCConvex Community
Created by Coffee11 on 6/20/2024 in #support-community
"in" filter keyword
ai chat in convex website?
10 replies
CCConvex Community
Created by Coffee11 on 6/21/2024 in #support-community
Need guidance on return types of query
flatMap what's magical about this it works as well!
7 replies
CCConvex Community
Created by Coffee11 on 6/21/2024 in #support-community
Need guidance on return types of query
Yep, I'll do this instead. By the way, thank you for the tip!
const userFavoriteCollections = await ctx.db
.query("favorite_listings")
.withIndex("by_user_id")
.filter((q) => q.eq(q.field("userId"), user._id))
.collect();

const userFavorites = await Promise.all(
userFavoriteCollections.map(async (userFavorite) => {
const propertyListing = await ctx.db.get(
userFavorite.propertyListingId
);

if (!propertyListing) {
return null;
}

return { ...propertyListing, favorite: true };
})
);

return userFavorites.filter(
(userFavorite): userFavorite is NonNullable<typeof userFavorite> =>
userFavorite !== null
);
const userFavoriteCollections = await ctx.db
.query("favorite_listings")
.withIndex("by_user_id")
.filter((q) => q.eq(q.field("userId"), user._id))
.collect();

const userFavorites = await Promise.all(
userFavoriteCollections.map(async (userFavorite) => {
const propertyListing = await ctx.db.get(
userFavorite.propertyListingId
);

if (!propertyListing) {
return null;
}

return { ...propertyListing, favorite: true };
})
);

return userFavorites.filter(
(userFavorite): userFavorite is NonNullable<typeof userFavorite> =>
userFavorite !== null
);
7 replies
CCConvex Community
Created by Coffee11 on 6/20/2024 in #support-community
"in" filter keyword
thank you @lee
10 replies
CCConvex Community
Created by Coffee11 on 6/20/2024 in #support-community
"in" filter keyword
will be querying _id
10 replies
CCConvex Community
Created by Coffee11 on 6/20/2024 in #support-community
"in" filter keyword
yes
10 replies
CCConvex Community
Created by Web Dev Cody on 4/20/2024 in #support-community
support for next-auth ur Lucia auth?
convex-auth the missing piece ❤️
26 replies
CCConvex Community
Created by Coffee11 on 6/19/2024 in #support-community
Drop table property with index
thanks @ian
3 replies
CCConvex Community
Created by FleetAdmiralJakob 🗕 🗗 🗙 on 3/21/2024 in #support-community
Find most similar value in Convex
Any updates?
17 replies
CCConvex Community
Created by Coffee11 on 6/12/2024 in #support-community
Production with react-native?
appreciate you both
11 replies
CCConvex Community
Created by Coffee11 on 6/12/2024 in #support-community
Production with react-native?
thank you @lee and @Riki
11 replies