Class: SchemaDefinition<Schema, StrictTableTypes>
For AI agents: see llms.txt for the complete documentation index. Markdown versions are available by adding .md to a page URL or requesting Accept: text/markdown.
server.SchemaDefinition
The definition of a Convex project schema.
This should be produced by using defineSchema.
Type parameters
| Name | Type |
|---|---|
Schema | extends GenericSchema |
StrictTableTypes | extends boolean |
Properties
tables
• tables: Schema
Defined in
strictTableNameTypes
• strictTableNameTypes: StrictTableTypes
Defined in
schemaValidation
• Readonly schemaValidation: boolean
Defined in
Methods
doc
▸ doc<TableName>(tableName): DocValidator<TableName, Schema[TableName]["validator"]>
The validator for whole documents of a table in this schema: the table's
own validator with the _id and _creationTime system fields added.
Example
export const get = query({
args: { id: schema.id("messages") },
returns: v.union(schema.doc("messages"), v.null()),
handler: (ctx, args) => ctx.db.get(args.id),
});
Type parameters
| Name | Type |
|---|---|
TableName | extends string |
Parameters
| Name | Type | Description |
|---|---|---|
tableName | TableName | The name of a table in this schema. |
Returns
DocValidator<TableName, Schema[TableName]["validator"]>
A validator matching documents of that table.
Defined in
id
▸ id<TableName>(tableName): VId<GenericId<TableName>, "required">
The validator for IDs of a table in this schema.
Same as v.id(tableName), but only accepts tables in this schema.
Type parameters
| Name | Type |
|---|---|
TableName | extends string |
Parameters
| Name | Type | Description |
|---|---|---|
tableName | TableName | The name of a table in this schema. |
Returns
VId<GenericId<TableName>, "required">
A validator matching IDs of that table.