Date and time when this query record was created
Date and time when this query record was last updated
When true, all executions of this query will be logged to the Audit Log system for tracking and compliance
When true, query results will be cached in memory with TTL expiration
Maximum number of cached result sets for this query. NULL uses default size limit.
Time-to-live in minutes for cached query results. NULL uses default TTL.
SQL query that returns cache validation fingerprint data (MaxUpdatedAt, RowCount). Used for smart cache refresh to determine if cached data is stale without fetching full results. When provided, enables efficient server-side cache validation before sending full query results.
The SQL should return exactly one row with two columns:
Example for a simple entity query:
SELECT MAX(__mj_UpdatedAt) AS MaxUpdatedAt, COUNT(*) AS RowCount FROM [schema].[EntityView]
For complex queries with filters/joins, the validation SQL should mirror the main query's data scope but only return the fingerprint metrics.
Category name from the related Query Categories entity
Foreign key reference to the Query Categories entity
Detailed description of what the query does and what data it returns
The AI Model name used to generate the embedding vector
The AI Model ID used to generate the embedding vector for this query. Required for vector similarity comparisons.
Optional JSON-serialized embedding vector for the query, used for similarity search and query analysis
User feedback on query accuracy, performance, or suggested improvements
Unique identifier for the query record
Name of the query for display and reference
The original SQL before any optimization or modification, kept for reference and comparison
JSON column containing platform-specific SQL variants for multi-database support. Stores alternative SQL for platforms other than the default (typically SQL Server). Parsed at runtime via GetPlatformSQL() and GetPlatformCacheValidationSQL().
Value indicating the quality of the query, higher values mean better quality
When true, this query can be referenced by other queries using {{query:"..."}} composition syntax. Only queries with Reusable=true AND Status='Approved' can be composed into other queries.
The actual SQL query text to execute, may include Nunjucks template parameters
Foreign key to the SQL dialect this query's SQL column is written in. Defaults to T-SQL for backward compatibility.
Current status of the query in the approval workflow
Technical documentation of the query logic, performance considerations, and parameter usage. Supports markdown content including mermaid diagrams.
Automatically set to true when the SQL column contains Nunjucks template markers like {{paramName}}
Gets the cache configuration for this query. If the query has no explicit cache config but category inheritance is enabled, walks up the category tree to find inherited cache settings.
The cache configuration or null if caching is disabled
Gets the category information for this query, supporting hierarchical organization.
The category this query belongs to, or undefined if not categorized
Gets the full hierarchical path of this query's category (e.g., "/MJ/AI/Agents/"). This provides a unique filepath-like identifier for the category hierarchy. Returns empty string if the query is not categorized.
The category path with leading and trailing slashes
Gets the dependency records for this query — other queries it references via {{query:"..."}} syntax.
Array of dependency records where this query is the referencing query
Gets queries that depend on (reference) this query via {{query:"..."}} syntax. Useful for impact analysis when changing or deprecating a reusable query.
Array of dependency records where this query is the referenced query
Gets the entities that are involved in this query, tracking which MemberJunction entities are referenced.
Array of entities used by the query
Gets the field metadata for this query, including display names, data types, and formatting rules.
Array of field metadata for the query
Whether this query has been formally approved for production use.
Whether this query can be referenced by other queries via composition syntax. A query is composable only when both Reusable=true and Status='Approved'.
Gets the parameter definitions for this parameterized query if it uses Nunjucks templates. Parameters include validation filters and metadata for type-safe query execution.
Array of parameter definitions for the query
Gets the permissions that control access to this query, defining which users and roles can run it.
Array of permission settings for the query
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
Resolves CacheValidationSQL for a given database platform. Checks PlatformVariants first; falls back to the base CacheValidationSQL property.
The target database platform
The appropriate CacheValidationSQL string, or null if none configured
Resolves the SQL for a given database platform. Resolution order:
The target database platform
The appropriate SQL string for the platform
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).
Checks if a user can run this query based on permissions. Non-approved queries are allowed to execute (with a server-side warning) to enable testing before formal approval.
The user to check
true if the user has permission to run the query
Checks if a user has permission to run this query based on their roles. A user can run a query if:
The user to check permissions for
true if the user has permission to run the query
Catalog of stored queries. This is useful for any arbitrary query that is known to be performant and correct and can be reused. Queries can be viewed/run by a user, used programatically via RunQuery, and also used by AI systems for improved reliability instead of dynamically generated SQL. Queries can also improve security since they store the SQL instead of using dynamic SQL.
Deprecated
Use
MJQueryEntityExtendedfrom@memberjunction/core-entitiesinstead.MJQueryEntityExtendedprovides the same child-relationship getters and business logic with event-driven cache invalidation viaQueryEngine.