AndersR
AndersR
CCConvex Community
Created by AndersR on 7/10/2023 in #support-community
Examples of many to many relationship?
I am testing out Convex by building a notes app, in which notes and topics have a M:M relationship. Are there good examples or suggested best practices for implementing this? The only thing I've seen is the convex demos example - https://github.com/get-convex/convex-demos/tree/main/relational-data-modeling, which is quite basic. I also looked in the docs but didn't see anything. Here are a couple examples of what I'd be interested in seeing examples of: - Create a topic and associate with a note. - Query a note and get associated topics. (several more but just focusing on those for now) Here is my current schema:
export default defineSchema({
notes: defineTable({
content: v.optional(v.string()),
ownerId: v.string(),
title: v.string(),
topics: v.array(v.id("topics")),
}),
topics: defineTable({
ownerId: v.string(),
title: v.string(),
}),
});
export default defineSchema({
notes: defineTable({
content: v.optional(v.string()),
ownerId: v.string(),
title: v.string(),
topics: v.array(v.id("topics")),
}),
topics: defineTable({
ownerId: v.string(),
title: v.string(),
}),
});
Is using an array of topic ids the correct way to go to make the association? When querying a note, how would I then collect and return the topics? I tried looping through each topic in the topic array and then doing a get on each topic but that did not work. Any tips or insights would be appreciated! Thanks!
7 replies
CCConvex Community
Created by AndersR on 7/3/2023 in #support-community
New project hangs at "Preparing convex functions..."
Hi, I am trying to add convex to an existing nextjs app. I ran npx project dev and selected create new project. However, now the process seems to hang at Preparing convex functions.. Any ideas why? here is the log, for reference
npx convex dev
What would you like to configure? a new project
Project name: <project name>
✔ Created project <project name>, manage it at https://dashboard.convex.dev/t/...
✔ Provisioned a dev deployment and saved its:
name as CONVEX_DEPLOYMENT to .env.local
URL as NEXT_PUBLIC_CONVEX_URL to .env.local

Write your Convex functions in convex/
Give us feedback at https://convex.dev/community or support@convex.dev

⠋ Preparing Convex functions...
npx convex dev
What would you like to configure? a new project
Project name: <project name>
✔ Created project <project name>, manage it at https://dashboard.convex.dev/t/...
✔ Provisioned a dev deployment and saved its:
name as CONVEX_DEPLOYMENT to .env.local
URL as NEXT_PUBLIC_CONVEX_URL to .env.local

Write your Convex functions in convex/
Give us feedback at https://convex.dev/community or support@convex.dev

⠋ Preparing Convex functions...
6 replies