Optionalmd: IMetadataProviderDate 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
Optional JSON configuration bag defining query-level policies and semantic capabilities (shape = IQueryConfiguration). Includes Priority (1-100) for ground-truth ranking in the semantic layer, LogExecution to control query execution logging, AlternativeQuestions for multi-phrasing vector recall, UsageGuidance and WhenNotToUse bounds for AI agents, and DomainScope.
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}}
Alternative questions, natural language phrasings, and query aliases for vector indexing. Returns empty array if none defined.
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
Parsed configuration object for this query. Lazily parsed and cached. Returns null if Configuration is not set or contains invalid JSON.
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
Operational domains or persona scopes where this query applies.
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 is designated as an enterprise ground-truth / canonical query. Defaults to false if not specified in Configuration.
Whether this query can be referenced by other queries via composition syntax. A query is composable only when both Reusable=true and Status='Approved'.
Whether executions of this query should be recorded in query execution logs. Defaults to true if not specified in Configuration.
The metadata provider that built this Info object, when known.
Info getters that resolve sibling metadata (an entity's IS-A children, a permission's RLS
filter, a query's fields, an authorization's roles, …) must read from the SAME provider the
object came from. In a multi-provider process — several GraphQLDataProvider instances with
separateConnection, or a server servicing several connections — the global
Metadata.Provider is a different provider or not set at all. Providers pass themselves to
every Info constructor (new m.class(row, provider)), and container Info objects hand it to
the child Info objects they construct.
undefined for an Info object built outside a provider (tests, ad-hoc construction). Callers
then fall back to the global provider, which is exactly the pre-existing behavior.
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
Priority ranking for semantic query selection (1-100). High values (e.g. 90-100) indicate authoritative, enterprise-certified ground truth queries. Defaults to 50 if not specified in Configuration.
Prescriptive guidance for AI agents on when to choose this query.
Explicit negative bounding / anti-patterns for AI agents.
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
OptionalskipKeys: ReadonlySet<string>Optional set of property keys handled directly by the subclass constructor
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
Records the provider that owns this Info object. A null/undefined provider is ignored, so passing an optional constructor argument straight through is always safe.
the provider whose metadata this object belongs to
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.
A _-backed getter that throws is omitted from the output rather than aborting the whole
serialization. That omission is safe ONLY because such getters are recomputable: the backing
field is a lazy cache over other serialized state (e.g. QueryInfo.CategoryPath over CategoryID),
so the value is rebuilt on the next access after a warm boot. Do not add a _-backed getter
whose value cannot be recomputed from the serialized fields — a throw would silently drop it.
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.