Data Object
DataObject
MPO Version: 1.3.0
A DataObject is the core building block of a service in Mindbricks. It represents both the data schema (like a table in SQL or a collection in MongoDB) and the business logic that operates around it. Each DataObject includes a set of DataProperties (fields), and it governs how the data is stored, validated, secured, and exposed through automatically generated business APIs. Beyond simple data modeling, DataObjects enable complex logic configurations, such as access control, field-level behaviors, validation, and custom API route behavior. They serve not only as data containers but also as logical units of functionality within the microservice.
interface DataObject = {
objectSettings : ObjectSettings;
properties : DataProperty[];
}
| Field | Description |
|---|---|
| objectSettings | Settings that define general behavior and characteristics of the data object, such as naming, indexing, visibility, and access options. |
| properties | The list of data properties of the data object. Each property represents a field and encapsulates both the type of the data and behavioral configurations like default values, constraints, visibility, or computed logic. Note: Mindbricks automatically creates standard fields (id, isActive, createdAt, updatedAt), so avoid defining these manually. |
ObjectSettings
MPO Version: 1.3.0
Configuration settings that govern the behavior, access control, and optimization strategies of a data object. These settings allow fine-grained control over how the data object behaves in terms of authorization, caching, indexing, payment processing, and membership relationships. This is the central point to define how the object integrates with infrastructure and security policies in a microservice.
interface ObjectSettings = {
basicSettings : ObjectBasicSettings;
authorization : ObjectAuthorization;
redisEntityCacheSettings : RedisEntityCacheSettings;
compositeIndexSettings : CompositeIndex[];
stripeOrder : StripeOrder;
membershipSettings : MembershipSettings;
}
| Field | Description |
|---|---|
| basicSettings | Core definitions of the data object such as its name, label, and description. These settings influence how the object appears in documentation and interfaces. |
| authorization | Rules and permissions that control access to this data object. These object-level rules enhance or override project-level authorization to implement fine-grained security models. |
| redisEntityCacheSettings | Configuration for enabling Redis-based entity-level caching. Useful for frequently accessed, lightweight records that benefit from high-speed lookups and smart cache invalidation. |
| compositeIndexSettings | Defines one or more composite indexes to ensure uniqueness across multiple fields and improve the efficiency of compound queries. This is especially critical for enforcing business constraints or query performance in relational databases. Please note that if you need unique constraints on a single field, you can use the unique property of the DataProperty instead. |
| stripeOrder | Activates e-commerce order support for the data object through Stripe integration. Automatically configures order and payment processing infrastructure when the object represents billable entities like purchases or subscriptions. |
| membershipSettings | Settings to enable access control for this object through an external membership relationship. This object represents the protected resource (such as a project), and access to it is managed by another object (such as projectMember) that links users or roles to this resource. Useful in multi-user collaboration domains where permissions are scoped per resource instance. |
ObjectBasicSettings
MPO Version: 1.3.0
Basic configuration for a data object, including its identity, documentation, and deletion strategy. A data object acts as a logical model for a database table or MongoDB collection, and is central to defining how data is stored, queried, and managed within a microservice.
interface ObjectBasicSettings = {
name : String;
description : Text;
frontendDocument : Text;
useSoftDelete : Boolean;
}
| Field | Description |
|---|---|
| name | A unique identifier for the data object used consistently across generated code, API routes, and documentation. The name must be a single, camelCase word without spaces or special characters, and should be unique within the project. Use a singular noun that clearly represents the entity (e.g., 'product', 'order', 'task'). |
| description | A descriptive explanation of what the data object represents. This description is used in documentation and helps clarify the business domain the object serves. |
| frontendDocument | A text based information to inform the frontend developer or frontend AI agent about the data object specific UX behaviour of the data object logic based on user stories and use cases. The format may be either text or markdown(recommended). Write the document as an AI prompt and describe data object specific UX behaviours. Note that this document will be given to the AI agent or human developer combined with all technical details that is generated from the data object design,so this document should only focus on data object-specific behavioral UX business logic. |
| useSoftDelete | Overrides the default data model setting to enable or disable soft deletion for this object. If enabled, records will not be physically deleted but marked inactive using an 'isActive' flag. These records will be excluded from normal queries unless explicitly requested. |
ObjectAuthorization
MPO Version: 1.3.0
Defines access control scope for this data object, including tenant scoping and public accessibility. These settings are applied globally unless explicitly overridden at the Business API level.
interface ObjectAuthorization = {
dataObjectAccess : DataObjectAccess;
objectDataIsInTenantLevel : Boolean;
}
| Field | Description |
|---|---|
| dataObjectAccess | Specifies the default access level for this DataObject and its related get/list APIs. The value is defined by the DataObjectAccess enum, which determines whether the object is private (restricted to owner/admins), protected (available to all authenticated project users), or public (open to everyone, including anonymous). API-level configurations may override this default. |
| objectDataIsInTenantLevel | Determines whether this object is scoped per tenant in a multi-tenant architecture. If true, an implicit tenant ID field (e.g., clientId) will be added to segregate data per tenant. Use this for tenant-owned data like projects or documents. |
DataObjectAccess
Defines the possible access levels for a DataObject. This type captures whether the object is only visible to its owner/admins (private), shared with authenticated project users (protected), or exposed to the public including anonymous users (public). The key difference is between restricted vs. shared access, and within shared access whether authentication is required.
const DataObjectAccess = {
accessPrivate: "accessPrivate",
accessProtected: "accessProtected",
accessPublic: "accessPublic",
};
| Enum | Description |
|---|---|
| accessPrivate | Only the object owner and system administrators can access. |
| accessProtected | All authenticated project users can access. |
| accessPublic | All users, including anonymous, can access. |
RedisEntityCacheSettings
MPO Version: 1.3.0
Configuration for Redis-based entity-level caching. Enables fast access to frequently used data by storing and serving object-level records from Redis, with support for custom cache criteria and smart expiration.
interface RedisEntityCacheSettings = {
useEntityCaching : Boolean;
configuration : RedisEntityCacheConfig;
}
| Field | Description |
|---|---|
| useEntityCaching | Enables Redis entity caching for this object. When active, individual records are cached in Redis, improving read performance for high-frequency access patterns. |
| configuration | Configuration settings for Redis entity caching. Includes cache criteria and expiration logic. Leave it null if useEntityCaching is false. |
RedisEntityCacheConfig
MPO Version: 1.3.0
Configuration for Redis-based entity-level caching. Enables fast access to frequently used data by storing and serving object-level records from Redis, with support for custom cache criteria and smart expiration.
interface RedisEntityCacheConfig = {
useSmartCaching : Boolean;
cacheCriteria : MScript;
checkCriteriaOnlyInCreateAndUpdates : Boolean;
}
| Field | Description |
|---|---|
| useSmartCaching | Activates smart cache expiration logic. TTL (time-to-live) is dynamically calculated based on access frequency, which is useful for large datasets with volatile usage patterns. |
| cacheCriteria | A condition (written as an MScript Query object) that determines whether a specific record should be cached. Useful for filtering which records are cache-worthy (e.g., only active events, unexpired tickets). |
| checkCriteriaOnlyInCreateAndUpdates | If true, cache criteria will be evaluated only during create and update operations, ideal for conditions based solely on internal record fields. Set false to re-evaluate criteria at read time when the condition depends on external context (e.g., current date). |
CompositeIndex
MPO Version: 1.3.0
Defines a composite index for a data object. Composite indexes improve database performance for queries that filter or sort based on multiple fields. Each index is created at the database level and can optionally handle duplicate conflicts during insert operations. Note that if you need unique constraints on a single field, you can use the unique property of the DataProperty instead. Composite indexes are particularly useful for optimizing complex queries that involve multiple fields, such as searching for users by email and client ID simultaneously or whne you need to ensure uniqueness across multiple fields (e.g., email and clientId). They are defined at the data object level and will be used across all related Business APIs.
interface CompositeIndex = {
indexName : String;
indexFields : PropRefer[];
onDuplicate : OnDuplicate;
}
| Field | Description |
|---|---|
| indexName | Unique name of the database index. Used in DDL statements and must be unique within the scope of the current data object. Choose a descriptive name that reflects the indexed fields (e.g., userEmailIndex). |
| indexFields | List of field names that form the composite index. The order of fields matters for query optimization. For example, ['email', 'clientId'] allows fast lookups for email within a specific client context. |
| onDuplicate | Defines the behavior when an insert operation encounters a duplicate key on this index. Options include updating the existing row or throwing an error. Useful for implementing upsert logic. |
OnDuplicate
Enumeration that defines the conflict resolution strategy when a new record would violate a composite index constraint.
const OnDuplicate = {
doUpdate: "doUpdate",
throwError: "throwError",
stopOperation: "stopOperation",
doInsert: "doInsert",
};
| Enum | Description |
|---|---|
| doUpdate | Update the existing record if a duplicate key is encountered. Equivalent to an upsert operation. |
| throwError | Throw a database error when a duplicate key is encountered. Prevents the insertion of conflicting data. |
| stopOperation | Stop the operation silently if a duplicate key is encountered. The existing record remains unchanged and no error is thrown. |
| doInsert | Proceed with the operation without checking for duplicates. Use this option when your composite index is designed for search purposes only and duplicates are allowed. |
StripeOrder
MPO Version: 1.3.0
Defines the settings for integrating this data object with Stripe to handle e-commerce orders and payments. When enabled, Mindbricks automatically generates the required logic and auxiliary objects for managing payment workflows. Ensure Stripe credentials are set at the project level to activate this integration.
interface StripeOrder = {
objectIsAnOrderObject : Boolean;
configuration : StripeOrderConfig;
}
| Field | Description |
|---|---|
| objectIsAnOrderObject | Enables Stripe order logic for this object. When true, the object is treated as an order and integrated with Stripe payment flows. |
| configuration | The configuration object for Stripe order integration. Leave it null if objectIsAnOrderObject is false. |
StripeOrderConfig
MPO Version: 1.3.0
Configuration settings for Stripe order integration. Defines the order name, ID, amount, currency, description, and other properties used in the Stripe payment flow.
interface StripeOrderConfig = {
orderName : String;
orderIdProperty : PropRefer;
amountProperty : PropRefer;
currencyProperty : PropRefer;
cuurencyStaticValue : String;
orderStatusProperty : PropRefer;
orderStatusUpdateDateProperty : PropRefer;
orderOwnerIdProperty : PropRefer;
description : MScript;
mapPaymentResultToOrderStatus : PaymentResultMap;
orderItemRelation : StripeOrderItemRelation;
afterPaymentCreations : AfterPaymentCreation[];
onPaymentError : OnPaymentError;
edgeFunctionOnStatusChange : String;
edgeFunctionPaymentDone : String;
}
| Field | Description |
|---|---|
| orderName | The name of the order as it will appear in Stripe and internal records. |
| orderIdProperty | The property name that holds the order's unique identifier. |
| amountProperty | The property name that holds the order amount for payment. |
| currencyProperty | The property name that holds the currency for the order. |
| cuurencyStaticValue | The static value of the currency for the order. If not set, the currency will be determined by the 'currencyProperty' . |
| orderStatusProperty | The field name in the data object that holds the current order status. This will be automatically updated based on payment results. |
| orderStatusUpdateDateProperty | The field name that records the timestamp of the last order status update. This is auto-managed during payment events. |
| orderOwnerIdProperty | The property name that holds the ID of the user who owns the order. This is used to ensure correct access control in payment flows. |
| description | MScript expression for the order description, shown in Stripe and receipts. |
| mapPaymentResultToOrderStatus | Defines how Stripe's payment results (started, success, failed, canceled) map to internal order statuses using MScript expressions. |
| orderItemRelation | Defines how this order object is related to its order item object. This relation enables post-payment bulk processing scenarios and can be reused by future order-based patterns. |
| afterPaymentCreations | Defines one or more automatic object creation tasks that run after a successful payment callback. Each task can create a single record or create records in bulk by looping through order items. |
| onPaymentError | Determines the system's behavior if a payment error occurs. Options are 'continueRoute' to proceed or 'throwError' to stop with an error. |
| edgeFunctionOnStatusChange | Optional name of an edge function that will be automatically triggered after any payment status change (e.g., payment completed, canceled, or failed). This event may be raised multiple times for the same payment (e.g., started, succeeded). IMPORTANT: This function MUST be defined in the service library's edgeFunctions array (NOT in the functions array). It must follow the standard edge function signature: module.exports = async (request) => { ... }. The system will automatically create a Kafka edge controller in the background — you do NOT need to define one manually. The edge function receives the latest order object data directly on the request (e.g., request.packagePurchase), along with session data when a user is logged in. Use this for non-critical operations like logging, notifications, or analytics that can tolerate duplicate calls. |
| edgeFunctionPaymentDone | Optional name of an edge function that will be triggered when a payment is successfully completed. Unlike edgeFunctionOnStatusChange (which fires on every status change from any payment API), this function is ONLY called from the payment callback and ONLY when the payment result is 'success'. It fires regardless of whether startPayment already marked the payment as successful (confirm-immediately flows). In rare cases where Stripe retries a failed callback, the event may fire again — so the edge function should be idempotent for critical operations (e.g., check if coins already exist before creating them). IMPORTANT: This function MUST be defined in the service library's edgeFunctions array (NOT in the functions array). It must follow the standard edge function signature: module.exports = async (request) => { ... }. The system will automatically create a Kafka edge controller in the background — you do NOT need to define one manually. Use this for critical post-payment operations like creating purchased resources (coins, credits, subscriptions), triggering fulfillment workflows, or any business logic that should only run after confirmed payment success. |
OnPaymentError
Enum options for handling errors that occur during the Stripe payment process.
const OnPaymentError = {
continueRoute: "continueRoute",
throwError: "throwError",
};
| Enum | Description |
|---|---|
| continueRoute | Continue processing, log the error, and set status to 'failed'. |
| throwError | Throw an error and halt processing when a payment error occurs. |
PaymentResultMap
MPO Version: 1.3.0
Defines how various Stripe payment outcomes map to internal order status values using MScript expressions.
interface PaymentResultMap = {
paymentResultStarted : MScript;
paymentResultCanceled : MScript;
paymentResultFailed : MScript;
paymentResultSuccess : MScript;
}
| Field | Description |
|---|---|
| paymentResultStarted | MScript for mapping the Stripe 'started' status to an internal order status. |
| paymentResultCanceled | MScript for mapping the Stripe 'canceled' status to an internal order status. |
| paymentResultFailed | MScript for mapping the Stripe 'failed' status to an internal order status. |
| paymentResultSuccess | MScript for mapping the Stripe 'success' status to an internal order status. |
StripeOrderItemRelation
MPO Version: 1.3.0
Defines the relation between the current order object and its order item object. This relation is used by payment-related automation patterns to fetch order items and run item-based operations.
interface StripeOrderItemRelation = {
hasOrderItemRelation : Boolean;
orderItemObject : LocalDataObjectName;
orderForeignKey : PropRefer;
orderItemLocalKey : PropRefer;
quantityProperty : PropRefer;
}
| Field | Description |
|---|---|
| hasOrderItemRelation | Enables order to orderItem relation mapping. When false, relation configuration is ignored. |
| orderItemObject | Order item data object name. This should be a local data object in the same service. |
| orderForeignKey | Property of the current order object that provides the value used to match order items. Commonly id. |
| orderItemLocalKey | Property of the order item object that stores the relation value to the order. Commonly orderId. |
| quantityProperty | Property of the order item object that stores item quantity for perOrderItemQuantity operations. Commonly quantity or qty. |
LocalDataObjectName
MPO Version: 1.3.0
Represents a reference to a data object within the same service. The value must be a simple object name; not a qualified reference in the format 'serviceName:objectName'.
interface LocalDataObjectName = {
}
| Field | Description |
|---|
AfterPaymentCreation
MPO Version: 1.3.0
Defines an automatic create operation that runs after successful payment completion of an order.
interface AfterPaymentCreation = {
name : String;
targetObject : DataObjectName;
emitMode : AfterPaymentEmitMode;
dataClause : DataMapItem[];
}
| Field | Description |
|---|---|
| name | Unique name of this post-payment creation task. |
| targetObject | Target data object to create. It can be a local object or a remote object in another service. |
| emitMode | Controls how many records are emitted for this creation rule. perOrder creates one record for the full order, perOrderItem creates one record for each order item, perOrderItemQuantity creates multiple records per order item according to stripeOrder.orderItemRelation.quantityProperty. |
| dataClause | Data map to construct the create payload. Values are MScript expressions and can reference order, orderItems, and when bulk mode is active, current orderItem. |
AfterPaymentEmitMode
Defines record emission strategy for AfterPaymentCreation.
const AfterPaymentEmitMode = {
perOrder: "perOrder",
perOrderItem: "perOrderItem",
perOrderItemQuantity: "perOrderItemQuantity",
};
| Enum | Description |
|---|---|
| perOrder | Create a single record for the full order. |
| perOrderItem | Create one record for each order item. |
| perOrderItemQuantity | Create multiple records per order item using stripeOrder.orderItemRelation.quantityProperty. |
MembershipSettings
MPO Version: 1.3.0
Configuration settings for membership-based access control of a data object. This object does not define access itself but relies on a separate membership data object to manage which users can access this data object. For example, an 'organization' object might have access control defined through an 'organizationMember' object, which holds references to both the user and the organization.
interface MembershipSettings = {
hasMembership : Boolean;
configuration : MembershipSettingsConfig;
}
| Field | Description |
|---|---|
| hasMembership | Indicates whether this data object uses an external membership object to manage access rights. If set to true, access to this object is governed by entries in another object. Default is false. |
| configuration | The configuration object for membership settings. Leave it null if hasMembership is false. |
MembershipSettingsConfig
MPO Version: 1.3.0
Configuration settings for membership-based access control of a data object. This object does not define access itself but relies on a separate membership data object to manage which users can access this data object. For example, an 'organization' object might have access control defined through an 'organizationMember' object, which holds references to both the user and the organization.
interface MembershipSettingsConfig = {
membershipObjectName : DataObjectName;
membershipObjectIdProperty : PropRefer;
membershipUserIdProperty : PropRefer;
membershipStatusCheck : MScript;
}
| Field | Description |
|---|---|
| membershipObjectName | Specifies the name of the external data object used to manage membership. This object contains membership entries linking users to this object. |
| membershipObjectIdProperty | The field name in the membership object that refers back to this data object (e.g., organizationId). It links the membership entry to this object. |
| membershipUserIdProperty | The field name in the membership object that refers to the user who holds membership. This is typically linked to the user's session during authorization checks. |
| membershipStatusCheck | Optional MScript condition to determine if a membership entry is valid. Can be used to check fields like status, startDate, or endDate. This filter is applied at query time when evaluating access. Example: { age: { $gte: 18 } } |
Last updated 4 weeks ago
Built with Documentation.AI