Corbi-Wan Kenobi
Corbi-Wan Kenobi
CCConvex Community
Created by Corbi-Wan Kenobi on 1/26/2025 in #support-community
COPPA compliance?
One of my projects is for the large private school I work at. I would need to store student data. COPPA (basically the student version of HIPPA) would be a factor. Would I want to use the open source convex and host onsite? When I was looking at Supabase they said that they needed some extra configuration if a project needed to be HIPPA compliant. Anything like that with Convex?
3 replies
CCConvex Community
Created by Corbi-Wan Kenobi on 1/26/2025 in #support-community
Using pagination in convex vs something like TanStack Tables?
I discovered convex via TanStack. I have a playground project where I got TanStack Tables working with pagination, sorting, and filtering all in one go. Benefits/drawbacks on using that over more hands-on coding with convex pagination and other coding to get the same results (dynamic filtering, sorting, address bar syncing and browser history consistency)?
22 replies
CCConvex Community
Created by Corbi-Wan Kenobi on 1/25/2025 in #support-community
How to tell the query to include specific fields
Instead of returning ALL of the fields in a document I want the query to only include specific fields. When I asked AI to help it said to put a .map function after the .query but when I do that I get a .map is not a function error. Ideally I want to specify the fields in the query, not in the return. Akin to select firstname, lastname from people where... as opposed to what is happening now which is select * from people where... What I tried based on AI. export default query(async (ctx) => { console.log("Write and test your query function here!"); return await ctx.db.query("people").map((person) => ({ nameFirst: person.name_first })).collect(); }) What get - Server Error Uncaught TypeError: ctx.db.query(...).map is not a function
10 replies
CCConvex Community
Created by Corbi-Wan Kenobi on 1/24/2025 in #support-community
Suggestions on schema best practice?
Bringin my data from postgres, this is one model I've been using and I'm wondering if this would not be better in convex as arrays. I'm coming from an SQL background with the usually weight on normalization. I have a people table, a phone_number_types table, and a person_numbers table linking the two with fireign keys (what is convex-speak for primary and foreign keys? same thing? Convex doesn't specificy foreign keys in their tables, right?). This allows for a given person to have one or more phone numbers attached to them with different types. Some people will only have one number, others will have several. I didn't want my people table to have fields for 5 possible types of numbers most of which would be empty for most people. I also have the same structure for email addresses and physical addresses. I'm wondering, from a convex perspective, is it better to store these kinds of things in array fields in the people table? It would mean far fewer relational joins, but I read in one of the docs it is better to not have too deeply nested of array fields. The array might look like {phone_numbers: {home: xxxxxxxxxx},{mobile: yyyyyyyyyy}} I actually had this a year or so ago when I was playing with MongoDB. Is it a matter of preference in this case since its really only a two level deep array?
3 replies
CCConvex Community
Created by Corbi-Wan Kenobi on 1/24/2025 in #support-community
Joining related tables help
There is a rough example of a join function in the convex docs that looks like this. export const eventAttendees = query({ args: { eventId: v.id("events") }, handler: async (ctx, args) => { const event = await ctx.db.get(args.eventId); return Promise.all( (event?.attendeeIds ?? []).map((userId) => ctx.db.get(userId)), ); }, }); I have a devices table that is related to a devices_makes and a devices_models table all by _id. Thanks to @lee 's help I got my foreign keys updated with migrations. No I just need help with how to join them so that I get something back like | devices:Asset Tag | devices_makes:Make | devices_model:Model | In the cited example an event can have many attendees (one-to-many). In this case mine are one-to-one. I've tried to plug in my own table and field names for just linking device_makes into the above examples but I get TypeScript Errors. I need some baby steps for join statements. Note to super Convex documentation people: it would be really helpful in the docs if you could include things like example schemas when giving example statements, especially for more complex things like joins.
38 replies
CCConvex Community
Created by Corbi-Wan Kenobi on 1/21/2025 in #support-community
I need to rekey my tables after importing
I'm used to a database-first development approach (only an SQL background) meaning that any modifications to the structure of my data/tables/relations, I have always managed directly in the database via SQL statements. I'm fully on-bard with Convex's mission and position on SQL, but I'm still in the early stages of the Mt Everest of learning curves for me. I've started small, imorting a primary table, some secondary tables (my terms) and a few many-to-many tables that link them. Since convex generates new unique row IDs, I would like to update/replace the values that make up all of the relationships in the many-to-many linking tables. What is the convex/JS way to do this, updating foreign keys based on new primary keys?
46 replies
CCConvex Community
Created by Corbi-Wan Kenobi on 1/18/2025 in #support-community
Convex Auth workflow
I'm converting from Remix/ReactRouter7 and Supabase to TanStack Start and Convex. I have this working in the other app and I'm having trouble knowing what to put where in "TanVex" or "ConStack" 🙂 Step 1 - User puts their email in a form for a Magic Link auth (which I have working on its own), and clicks the button. Step 2 - I need convex to take the submitted email address, query my "people" table and check if (a) the email exists/is connected to a user and (b) the "can_login" boolean for the user is set to true. Here is how I'm capturing the email address and sending it to the query: const formData = new FormData(event.currentTarget); const submittedEmail = formData.get("email"); const { data } = useSuspenseQuery(convexQuery(api.personEmails.checkCanLogin, {email_address: submittedEmail})); I have that happening in the sample login form linked below (between lines 58 and 59). I don't know how to grab and use the submittedEmail in the query I'm working on in the personEmails.checkCanLogin, nor do I know how to return back to the login page that requested it. Step 3 - If the tests pass, proceed with the magic link process and display a "check your email" message. If the tests fail, show a "that address is not authorized" message. I was working with the sample login form located here as a template (https://github.com/get-convex/convex-auth-example/blob/main/src/auth/SignInFormEmailLink.tsx). I'm new to both Convex and Tanstack. I haven't figured out how to pass the formData email to the convex query that I've put in a person_emails.ts file. That's where I'm stuck. I'll of course need to return the results. There are great examples of pulling all rows from a table in the docs. I can't find good examples of accepting, passing, and returning things like this search. I'm guessing its framework specific. I get Remix/RR7 loaders and actions, I'm having trouble bridging the concepts here.
7 replies
CCConvex Community
Created by Corbi-Wan Kenobi on 1/15/2025 in #support-community
Dumb question: how do I make it stop looking for the sample data?
I installed the convex and tanstack start template. New to both. Every time I npm run dev I see a warning that it can't find the sample.json file which I did delete. How do I make convex stop looking for that?
7 replies
CCConvex Community
Created by Corbi-Wan Kenobi on 1/14/2025 in #support-community
Working on importing/migrating from another database
I'm just starting to experiment with migrating data over from Postgres. I see that "each row's entries are interpreted either as a (floating point) number or a string." Got it. However, when I do the import (csv), every value ends up in convex with quotation marks around it. This is messing up my boolean fields. How can I find/replace/update all rows/fields where I have a boolean so that it removes the quotation marks?
3 replies