Collection of all joined field mappings from the related entity.
Mirror of IsComputed on the related entity's Name Field. Tracked alongside
_RelatedEntityNameFieldIsVirtual so that base-view JOIN-target selection can
prefer the related entity's base table when the Name Field is a SQL computed/
generated column (physically present in the base table even though IsVirtual=1).
Controls whether encrypted fields are decrypted when returned via API.
When true:
When false:
Optional property that provides the display name for the field, if null, use the Name property. The DisplayNameOrName() method is a helper function that does this for you with a single method call.
When true, this field will be encrypted at rest using the specified EncryptionKeyID. Encrypted fields:
References the encryption key to use when Encrypt is true. Must point to an active record in the "MJ: Encryption Keys" entity. Required if Encrypt is true.
Foreign key to the Entities entity.
Primary Key
When true, this field is a SQL Server computed column or PostgreSQL generated column — physically present in the base table but read-only at the SQL layer. Distinct from IsVirtual, which is also set to 1 for these fields (because they are read-only at the API layer) but is additionally set for view-only columns that don't exist in the base table at all (e.g., joined name lookups in the base view). Use the combination to disambiguate: IsVirtual=0, IsComputed=0 → regular base-table column (writable) IsVirtual=1, IsComputed=0 → view-only column (no physical storage) IsVirtual=1, IsComputed=1 → computed/generated column (physical, read-only in SQL) Only relevant downstream consumer that branches on this is base-view JOIN target selection in CodeGen — when an FK's related Name Field is IsComputed=1, the join targets the related entity's base table (not its view).
If true, the field is the primary key for the entity. There must be one primary key field per entity.
Indicates this field is a soft foreign key (metadata-defined, not a database constraint). When set to 1, RelatedEntityID and RelatedEntityFieldName are preserved and not overwritten by CodeGen schema sync.
Indicates this field is a soft primary key (metadata-defined, not a database constraint). The view ORs this with IsPrimaryKey, so existing code checking IsPrimaryKey works automatically.
If true, the field is a unique key for the entity. There can be zero to many unique key fields per entity.
The name of the TypeScript interface/type for this JSON field. When set, CodeGen will emit a strongly-typed getter/setter using this type instead of the default string getter/setter.
Raw TypeScript code emitted by CodeGen above the entity class definition. Typically contains the interface/type definition referenced by JSONType. Can include imports, multiple types, or any valid TypeScript.
If true, the field holds a JSON array of JSONType items. The getter returns JSONType[] | null and the setter accepts JSONType[] | null.
JSON configuration for additional fields to join from the related entity. Parsed from the RelatedEntityJoinFields column.
When AllowDecryptInAPI is false, controls what value is returned to clients.
When true:
When false:
The sequence of the field within the entity, typically the intended display order
Search predicate controlling how user-search queries match against this field in the LIKE-based search path used when the entity does not have FullTextSearchEnabled. Valid values: 'BeginsWith' | 'Contains' | 'EndsWith' | 'Exact'. Default 'Contains'. Honored by GenericDatabaseProvider.createViewUserSearchSQL.
Returns the DisplayName if it exists, otherwise returns the Name.
Returns true if the field's SQL type is fixed-width / space-padded
(SQL Server char/nchar, PostgreSQL char/character/bpchar).
Authoritative source is @memberjunction/sql-dialect so the list of
fixed-width types stays in one place per dialect. BaseEntity reads
this on value-set to rtrim padding the DB returned, preventing
spurious dirty-flagging when application code stores the logical
(un-padded) form of the value.
Returns true if the field has a default value set
Returns true if the field type is a binary type such as binary, varbinary, or image.
Returns true if the field is the CreatedAt field, a special field that is used to track the creation date of a record. This is only used when the entity has TrackRecordChanges=1
Returns true if the field is the DeletedAt field, a special field that is used to track the deletion date of a record. This is only used when the entity has DeleteType=Soft
Helper method that returns true if the field is one of the special reserved MJ date fields for tracking CreatedAt and UpdatedAt timestamps as well as the DeletedAt timestamp used for entities that have DeleteType=Soft. This is only used when the entity has TrackRecordChanges=1 or for entities where DeleteType=Soft
Returns true if the field is a GUID/UUID column in the database.
Accepts both the SQL Server type name (uniqueidentifier) and the
PostgreSQL type name (uuid) — on PG the metadata Type is reported as
uuid, so a uniqueidentifier-only check would miss every UUID column.
Returns true if the field is the UpdatedAt field, a special field that is used to track the last update date of a record. This is only used when the entity has TrackRecordChanges=1
Returns true when the field's spUpdate / spCreate procedure
exposes a <Param>_Clear companion parameter — i.e. the field is
nullable and has a non-NULL database default.
Codegen emits the companion so a caller can disambiguate
"leave unchanged / apply default" (omit the parameter) from
"explicitly set this column to NULL" (<Param>_Clear = 1).
Without it, the SP body's ISNULL(@Param, [Col]) merge silently
substitutes the existing value or default, and a literal NULL
could never be persisted.
Save-time callers in the data providers use this to decide whether
to also emit the _Clear companion parameter when the entity
intentionally sets such a field to NULL. Stays in sync with
CodeGenLib's needsClearCompanion.
Note: relies on DefaultValue already being normalized by
ExtractActualDefaultValue at populate time — that helper strips
the DB's wrapping parens and converts a literal NULL default to
JS null. So if HasDefaultValue is true, the default is
guaranteed to be non-NULL.
Returns true if the field type requires quotes around the value when used in a SQL statement
JSON configuration for additional fields to join from the related entity. Parsed from the RelatedEntityJoinFields column. Uses lazy initialization and caching to avoid repeated JSON.parse calls. If parsing fails, it won't be attempted again.
Returns true if the field type requires a Unicode prefix (N) when used in a SQL statement.
Returns true if the field is a "special" field (see list below) and is handled inside the DB layer and should be ignored in validation by the BaseEntity architecture Also, we skip validation if we have a field that is:
Returns a string with the full SQL data type that combines, as appropriate, Type, Length, Precision and Scale where these attributes are relevant to the Type
Provides the TypeScript type for a given Entity Field. This is useful to map a wide array of database types to a narrower set of TypeScript types.
Memoized: this getter is read per-field on extremely hot paths (the EntityField
value getter/setter, BaseEntity.Set/SetMany, dirty-tracking, hydration, and the
raw-mode Get() date check). Recomputing the SQL→TS classification (which runs
several string-matching helpers + toLowerCase) on every access is wasteful since
Type never changes after load.
Returns the Unicode prefix (N) if the field type requires it, otherwise returns an empty string.
Returns the ValueListType using the EntityFieldValueListType enum.
ProtectedcopyCopies initialization data from a plain object to the class instance. Only copies properties that already exist on the class to prevent creating new fields. Special handling for DefaultValue fields to extract actual values from SQL Server syntax.
The initialization data object
Formats a value based on the parameters passed in. This is a wrapper utility method that already know the SQL type from the entity field definition and simply calls the generic FormatValue() function that is also exported by @memberjunction/core
Value to format
Number of decimals to show, defaults to 2
Currency to use when formatting, defaults to USD
Maximum length of the string to return, if the formatted value is longer than this length then the string will be truncated and the trailingChars will be appended to the end of the string
Only used if maxLength is > 0 and the string being formatted is > maxLength, this is the string that will be appended to the end of the string to indicate that it was truncated, defaults to "..."
either the original string value or a formatted version. If the format cannot be applied an an exception occurs it is captured and the error is put to the log, and the original value is returned
Returns true when this field appears as a parameter in the entity's
spCreate (when isUpdate=false) or spUpdate (when isUpdate=true)
stored procedure.
This is the single source of truth for the SP parameter contract, consumed by both:
• CodeGen, when emitting the SP body (which @params to declare
and which columns to INSERT/UPDATE), and
• Runtime data providers, via the RenderSaveCallBinding hook
implemented by SQLServerDataProvider and PostgreSQLDataProvider
(orchestrated by GenericDatabaseProvider.GenerateSaveSQL), when
building the EXEC / parameter list passed to the SP.
Keeping both sides on the same predicate guarantees the SP signature and the call-site argument list always agree. Drift between them surfaces as a SQL Server "Procedure or function ... has too many arguments specified" error at save time (or its PG equivalent).
Exclusion rules (in order):
• IsVirtual — view-only / joined columns. Not present in the base
table; the SP body never references them. Also covers IS-A parent
fields on child entities — those are saved via the parent's SP,
not the child's, so they must not appear in the child's SP params.
• IsComputed — SQL Server computed columns and PG generated
columns. Physically present in the base table but read-only at
the SQL layer (INSERT/UPDATE cannot target them). Today
IsComputed=1 implies IsVirtual=1, but checking both is
defensive against future decoupling of the flags.
• IsSpecialDateField — __mj_CreatedAt, __mj_UpdatedAt,
__mj_DeletedAt. Set inside the SP body / trigger from
GETUTCDATE() rather than by the caller.
• Non-PK fields without AllowUpdateAPI — by definition not
callable via the SP signature.
PK handling:
• On update, the PK is always a parameter (required to identify
the row).
• On create, the PK is a parameter only when it's NOT
auto-increment — the SP body declares it with a default so the
caller can either supply a value or let the database default fire
(e.g. NEWSEQUENTIALID()). For auto-increment PKs, the SP
intentionally doesn't expose the PK as a parameter.
true for spUpdate, false for spCreate.
Default JSON serialization for BaseInfo subclasses.
Emits all non-underscored direct field declarations. For _-prefixed private backing fields
(the MJ pattern for collection storage — e.g. _Fields, _RelatedEntities, _OrganicKeys),
emits the value of the corresponding same-named public getter instead. Purely computed getters
without a backing field (display-name formatters, derived flags) are intentionally skipped —
they can throw when source fields are null and don't belong on the wire anyway.
Nested BaseInfo instances and arrays of them unwrap automatically via JSON.stringify's native toJSON() protocol.
Subclasses may override to emit a filtered subset or custom shape (see EntityFieldValueInfo).
StaticAssertThis static factory method is used to check to see if the entity field in question is active or not If it is not active, it will throw an exception or log a warning depending on the status of the entity field being either Deprecated or Disabled.
the EntityFieldInfo object to check the status of
the name of the caller that is calling this method, used for logging purposes such as EntityField::constructor as an example.
StaticIsChecks if a default value is a SQL Server function that returns the current date/time
The default value to check
true if the default value is a SQL current date/time function, false otherwise
List of all fields within each entity with metadata about each field. Includes data types, relationships, defaults, and UI display preferences.