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
Value indicating the quality of the query, higher values mean better quality
The actual SQL query text to execute, may include Nunjucks template parameters
Current status of the query in the approval workflow
Automatically set to true when the SQL column contains Nunjucks template markers like {{paramName}}
Date and time when this query record was created
Date and time when this query record was last updated
Private _cachePrivate _categoryPrivate _entitiesPrivate _fieldsPrivate _parametersGets 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 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
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
Checks if a user can run this query, considering both permissions and query status. A query can be run if:
The user to check
true if the user can run the query right now
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
Private buildProtected copyCopies 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
Private getWalks up the category hierarchy to find inherited cache configuration.
The inherited cache config or null if none found
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.