Danny I
Danny I
CCConvex Community
Created by Danny I on 9/30/2024 in #support-community
Chat app, only one messages table?
Hi, I am effectively working on a chat app, but, I am concerned that my messages table will have too many entries. Is this something I should be concerned about?
3 replies
CCConvex Community
Created by Danny I on 9/23/2024 in #support-community
Sign up user with custom fields
(Using convex auth/Password) Hey, so following the docs, I need custom fields for my users (who doesn't?), so I make a custom Password provider as specified for the password sign in/up function. But now when I need to set up email verification, the custom Password provider is erroring, since it's not callable. Code:
import Password from "./CustomPassword";

export const { auth, signIn, signOut, store } = convexAuth({
providers: [Password({ verify: ResendOTP })] // <-- This is not callable
});
import Password from "./CustomPassword";

export const { auth, signIn, signOut, store } = convexAuth({
providers: [Password({ verify: ResendOTP })] // <-- This is not callable
});
https://labs.convex.dev/auth/config/passwords#email-verification-setup And the custom provider šŸ¤·šŸ»ā€ā™‚ļø Does it only run on sign up? Is it okay to initialize values for new accounts here?
import { Password } from "@convex-dev/auth/providers/Password";
import { DataModel } from "./_generated/dataModel";
import { z } from "zod";
import { ConvexError } from "convex/values";

const ParamsSchema = z.object({
email: z.string().email(),
password: z.string().min(16),
});


export default Password<DataModel>({
profile(params) {
const { error, data } = ParamsSchema.safeParse(params);
if (error) {
throw new ConvexError(error.format());
}
return {
email: params.email as string,
name: params.name as string,
accountType: params.accountType as 'personal' | 'business',
businesses: params.accountType === 'business' ? [] : null,
businessName: params.accountType === 'business' ? params.businessName as string : null,
conversationIds: [],
};
},
});
import { Password } from "@convex-dev/auth/providers/Password";
import { DataModel } from "./_generated/dataModel";
import { z } from "zod";
import { ConvexError } from "convex/values";

const ParamsSchema = z.object({
email: z.string().email(),
password: z.string().min(16),
});


export default Password<DataModel>({
profile(params) {
const { error, data } = ParamsSchema.safeParse(params);
if (error) {
throw new ConvexError(error.format());
}
return {
email: params.email as string,
name: params.name as string,
accountType: params.accountType as 'personal' | 'business',
businesses: params.accountType === 'business' ? [] : null,
businessName: params.accountType === 'business' ? params.businessName as string : null,
conversationIds: [],
};
},
});
43 replies
CCConvex Community
Created by Danny I on 9/19/2024 in #support-community
How to check which user is signed in
Sorry all, I just can't find it in the docs. I found an article but the method shown is now deprecated. I'm using the convex auth implementation in react/expo, I assumed there would be a hook for the current user? šŸ™‡šŸ»ā€ā™‚ļø
6 replies
CCConvex Community
Created by Danny I on 8/21/2024 in #support-community
Correct pattern for running a query onClick without re-running on re-render.
Hi, newbie in need of advice. Using React(Native), I am taking a document name from a user via a textInput field and onClick I want to check if that document exists. I don't want to run the query everytime the user types something...
export default function Home() {
const [conversationName, setConversationName] = useState(''); // Updates the component
const addConversation = useMutation(api.conversations.createConversation);

const handleStart = async () => {
const conversationExists = await useQuery(api.conversations.exists, { name: conversationName as string });
if (!conversationExists) {
await addConversation({ name: conversationName as string, owner: "owner", participants: ["Danny"] });
}
router.push({ pathname: `/${conversationName}` });
};

return ...
export default function Home() {
const [conversationName, setConversationName] = useState(''); // Updates the component
const addConversation = useMutation(api.conversations.createConversation);

const handleStart = async () => {
const conversationExists = await useQuery(api.conversations.exists, { name: conversationName as string });
if (!conversationExists) {
await addConversation({ name: conversationName as string, owner: "owner", participants: ["Danny"] });
}
router.push({ pathname: `/${conversationName}` });
};

return ...
Can anyone advise me on the correct way to do this? Thank you! šŸ™‡šŸ»ā€ā™‚ļø šŸ™šŸ¼
3 replies