Module: values
Utilities for working with values stored in Convex.
You can see the full set of supported types at Types.
Namespaces
Classes
Type Aliases
PropertyValidators
Ƭ PropertyValidators: Record
<string
, Validator
<any
, any
, any
>>
Validators for each property of an object.
This is represented as an object mapping the property name to its Validator.
Defined in
ObjectType
Ƭ ObjectType<Validators
>: Expand
<{ [Property in OptionalKeys<Validators>]?: Validators[Property]["type"] } & { [Property in RequiredKeys<Validators>]: Validators[Property]["type"] }>
Compute the type of an object from PropertyValidators.
Type parameters
Name | Type |
---|---|
Validators | extends PropertyValidators |
Defined in
Infer
Ƭ Infer<V
>: V
["type"
]
Extract a TypeScript type from a validator.
Example usage:
const objectSchema = v.object({
property: v.string(),
});
type MyObject = Infer<typeof objectSchema>; // { property: string }
Type parameters
Name | Type | Description |
---|---|---|
V | extends Validator <any , any , any > | The type of a Validator constructed with v. |
Defined in
JSONValue
Ƭ JSONValue: null
| boolean
| number
| string
| JSONValue
[] | { [key: string]
: JSONValue
; }
The type of JavaScript values serializable to JSON.
Defined in
GenericIdConstructor
Ƭ GenericIdConstructor<TableNames
>: Object
Type parameters
Name | Type |
---|---|
TableNames | extends string |
Call signature
• new GenericIdConstructor<TableName
>(tableName
, id
): GenericId
<TableName
>
Internal type used in Convex code generation.
Type parameters
Name | Type |
---|---|
TableName | extends string |
Parameters
Name | Type |
---|---|
tableName | TableName |
id | string |
Returns
GenericId
<TableName
>
Type declaration
Name | Type |
---|---|
prototype | GenericId <string > |
fromJSON | (obj : any ) => GenericId <string > |
Defined in
Value
Ƭ Value: GenericId
<string
> | null
| bigint
| number
| boolean
| string
| ArrayBuffer
| Value
[] | Set
<Value
> | Map
<Value
, Value
> | { [key: string]
: undefined
| Value
; }
A value supported by Convex.
Values can be:
- stored inside of documents.
- used as arguments and return types to queries and mutation functions.
You can see the full set of supported types at Types.
Defined in
NumericValue
Ƭ NumericValue: bigint
| number
The types of Value that can be used to represent numbers.
Defined in
Variables
v
• Const
v: Object
The validator builder.
This builder allows you to build validators for Convex values.
Validators can be used in schema definitions and as input validators for Convex functions.
Type declaration
Name | Type |
---|---|
id | <TableName>(tableName : TableName ) => Validator <GenericId <TableName >, false , never > |
null | () => Validator <null , false , never > |
number | () => Validator <number , false , never > |
bigint | () => Validator <bigint , false , never > |
boolean | () => Validator <boolean , false , never > |
string | () => Validator <string , false , never > |
bytes | () => Validator <ArrayBuffer , false , never > |
literal | <T>(literal : T ) => Validator <T , false , never > |
array | <T>(values : Validator <T , false , any >) => Validator <T [], false , never > |
set | <T>(values : Validator <T , false , any >) => Validator <Set <T >, false , never > |
map | <K, V>(keys : Validator <K , false , any >, values : Validator <V , false , any >) => Validator <Map <K , V >, false , never > |
object | <T>(schema : T ) => ObjectValidator <T > |
union | <T>(...schemaTypes : T ) => Validator <T [number ]["type" ], false , T [number ]["fieldPaths" ]> |
any | () => Validator <any , false , string > |
optional | <T>(inner : T ) => Validator <undefined | T ["type" ], true , T ["fieldPaths" ]> |
Defined in
Functions
jsonToConvex
▸ jsonToConvex(value
): Value
Parse a Convex value from its JSON representation.
This function will revive classes like GenericId that have been serialized to JSON, parse out BigInt
s, and so on.
To learn more about Convex values, see Types.
Parameters
Name | Type | Description |
---|---|---|
value | JSONValue | The JSON representation of a Convex value previously created with convexToJson. |
Returns
The JavaScript representation of the Convex value.
Defined in
convexToJson
▸ convexToJson(value
): JSONValue
Convert a Convex value to its JSON representation.
Use jsonToConvex to recreate the original value.
To learn more about Convex values, see Types.
Parameters
Name | Type | Description |
---|---|---|
value | Value | A Convex value to convert into JSON. |
Returns
The JSON representation of value
.