DiamondDragon
DiamondDragon
CCConvex Community
Created by DiamondDragon on 12/11/2024 in #support-community
Returning data from Tanstack Query useMutation wrapper
No description
3 replies
CCConvex Community
Created by DiamondDragon on 12/3/2024 in #support-community
Zod Unions appear to break `Table` helper (maybe zodToConvex related?)
No description
1 replies
CCConvex Community
Created by DiamondDragon on 12/1/2024 in #support-community
Handling Upserts with Optional System Fields
Not sure if this is the best practice here but didn't appear there's a way of getting the Id field to be optional so it can be passed in for upserts (if it doesn't exist, insert, if it does patch). Not sure if my types are entirely correct but seems to work but happy to hear if anyone else agrees
function upsertDeal(ctx: MutationCtx, args: MakeIdOptional<Deals>) {
if (args._id) { // type _id = string & {} | undefined
return ctx.db.patch(args._id, args)
}

return insertDeal(ctx, args)
}


// Make only _id optional and exclude _creationTime for upserts
export type MakeIdOptional<T> = Omit<T, '_id' | '_creationTime'> & {
_id?: T extends { _id: Id<any> } ? Id<any> : never
}
function upsertDeal(ctx: MutationCtx, args: MakeIdOptional<Deals>) {
if (args._id) { // type _id = string & {} | undefined
return ctx.db.patch(args._id, args)
}

return insertDeal(ctx, args)
}


// Make only _id optional and exclude _creationTime for upserts
export type MakeIdOptional<T> = Omit<T, '_id' | '_creationTime'> & {
_id?: T extends { _id: Id<any> } ? Id<any> : never
}
3 replies
CCConvex Community
Created by DiamondDragon on 11/26/2024 in #support-community
HTTP Path Suffix Not Working?
No description
7 replies
CCConvex Community
Created by DiamondDragon on 10/16/2024 in #support-community
Unable to get Tanstack Trellaux Start working
No description
7 replies