Schemas vs Schemaless
So I have a conceptual question about convex! I was doing the counter/messages tutorial and adding the code for the messages portion seems to break the counter portion (I haven't updated App.tsx yet, only listMessage and sendMessage)
is it possible to leave both of these parts intact, or can you only interact with one db table at a time?
4 Replies
Do you have a
convex/schema.ts
file?
The type of db
is based on the schema you defined. It seems like maybe your schema only includes messages
and not counter_table
?
If thats the case you can either:
- Update the schema to get the TypeScript types for both
- Or delete the schema.ts
file to get permissive types that will work for all tables/documents
More info at https://docs.convex.dev/using/schemasDefining a Schema | Convex Developer Hub
A schema is a description of
so I just created the
convex/schema.ts
as part of this tutorial https://docs.convex.dev/getting-started/basics/chat-app. i don't think it existed before this. how was the original counter_table running (as part of the first tutorial https://docs.convex.dev/getting-started/hello-convex as I don't think there was a schema.ts during this part?Hello Convex | Convex Developer Hub
This tutorial will teach you how to set up your first Convex app. Let's get
If you don't have a schema, Convex's code generation will allow any string as a table name, documents are typed as
any
, etc. Once you define a schema Convex expects your code to match it.
The first tutorial works because it is schemaless (we wanted to put off introducing schemas until the chat app to keep the intro simple)
But yeah, sorry about the confusing tutorial here! We're working on streamlining it to one app and I think that'll make this less confusinggot it, that makes sense!! thank you!!