Reference Field Types - osama1998H/Moca GitHub Wiki

Field Types Reference

All 35 FieldTypes with PostgreSQL mapping, validation, and API representation.

Storage Field Types (29)

FieldType Category PostgreSQL Type Description
Data Text VARCHAR(140) Short text input
Text Text TEXT Long text (plain)
Small Text Text TEXT Short multiline text
Long Text Text TEXT Long text area
Text Editor Text TEXT Rich text (HTML)
Markdown Editor Text TEXT Markdown content
Code Text TEXT Code editor
HTML Editor Text TEXT Raw HTML
Password Text TEXT Masked input; encrypted at rest when field encryption is enabled
Int Number INTEGER Integer
Float Number DOUBLE PRECISION Floating point
Currency Number NUMERIC(18,6) Monetary value
Percent Number DOUBLE PRECISION Percentage (0-100)
Rating Number DOUBLE PRECISION Star rating (0-1)
Check Boolean BOOLEAN Checkbox
Date DateTime DATE Date picker
Datetime DateTime TIMESTAMP Date + time
Time DateTime TIME Time picker
Duration DateTime DOUBLE PRECISION Duration in seconds
Select Choice VARCHAR(140) Dropdown (options: \n-separated)
Link Reference VARCHAR(140) Foreign key to another DocType
Dynamic Link Reference VARCHAR(140) Polymorphic link (target in another field)
Table Child (separate table) Embedded child table
Table MultiSelect Child (join table) Multi-select via link table
Attach File TEXT File attachment (URL)
Attach Image File TEXT Image attachment (URL)
Color Special VARCHAR(140) Color picker (#hex)
Geolocation Special TEXT Lat/lng JSON
JSON Special JSONB Arbitrary JSON data

Layout Field Types (6)

These fields do not store data -- they control form layout:

FieldType Purpose
Section Break Start a new section
Column Break Start a new column in current section
Tab Break Start a new tab
Heading Display heading text
HTML Render static HTML
Button Action button

Field Options

The options property has type-specific meanings:

FieldType Options Meaning Example
Select Newline-separated values "Open\nClosed\nPending"
Link Target DocType name "User"
Table Child DocType name "Order Item"
Data Validation type "Email", "URL", "Phone"

Password Field Notes

Password fields are regular document fields, not the special login-password storage used by the builtin User doctype.

  • when MOCA_ENCRYPTION_KEY is set, Password field values are encrypted before save and transparently decrypted on reads
  • when field encryption is not enabled, the field stores plain text in the document table
  • encrypted values are stored in TEXT columns with an enc:v1: prefix

Related