keyValue
keyValue<
TCollectionSlug,TFieldKey,TFieldMeta,TKeysSlug>(options):KeyValueField<TCollectionSlug,TFieldMeta,TKeysSlug>
Defined in: packages/core/src/fields/keyValue/config.ts:46
Creates a keyValue field with all defaults applied.
KeyValue fields store a Convex v.record(keys, value) — a dynamically-keyed
map from keys (v.string(), or v.id(collection) when keys is set) to
one shared value data field. value’s own required is forced to true
(record values can’t be v.optional in Convex); its nullable still
applies.
Defaults applied:
label—""(inferred from the field key bydefineCollection)required—falsedefaultValue—{}admin.hidden—falseadmin.readOnly—falseadmin.position—"main"admin.width—"100%"admin.cellAlignment—"left"admin.defaultCollapsed—false
Type Parameters
Section titled “Type Parameters”TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends string = string
TFieldKey
Section titled “TFieldKey”TFieldKey extends string = never
TFieldMeta
Section titled “TFieldMeta”TFieldMeta extends BaseFieldMeta = BaseFieldMeta
TKeysSlug
Section titled “TKeysSlug”TKeysSlug extends string = string
Parameters
Section titled “Parameters”options
Section titled “options”KeyValueFieldInput<TCollectionSlug, TFieldKey, TFieldMeta, TKeysSlug>
KeyValue field configuration. value is required; all
other properties are optional.
Returns
Section titled “Returns”KeyValueField<TCollectionSlug, TFieldMeta, TKeysSlug>
Resolved keyValue field definition with all defaults applied.
Example
Section titled “Example”import { keyValue, number } from "@vexcms/core"
storageShapes: defineCollection({ fields: { scores: keyValue({ label: "Scores", value: number({ required: true }) }), },})- KeyValueFieldInput for the full input type
- KeyValueField for the resolved output type