The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
---
title: "Order group data models"
sidebarTitle: "Data models"
description: "Fields, indexes, and relations of the OrderGroup data model in the Seller module."
---
Order groups have one data model, `OrderGroup`, registered on the Seller module. There is no separate order group module: resolve it with `MercurModules.SELLER`. The model is defined in `packages/core/src/modules/seller/models/order-group.ts`, and its record type is `OrderGroupDTO` from `@mercurjs/types`.
## OrderGroup
The parent record over the child orders created from one completed cart. Table `order_group`, id prefix `og`.
| Field | Type | Description |
| --- | --- | --- |
| `id` | `text` | Primary key with the prefix `og` |
| `display_id` | `autoincrement` | Integer assigned by the database in creation order, for people to quote |
| `customer_id` | `text`, nullable | Id of the customer on the completed cart, or `null` when the cart had none |
| `cart_id` | `text` | Id of the completed cart; backs the read-only link to the Cart module |
| `seller_count` | `number`, computed | Number of distinct sellers across the group’s child orders; not stored |
| `total` | `bigNumber`, computed | Sum of the child orders’ `current_order_total`; not stored, returned as a `number` |
| `created_at` | `dateTime` | Set when the record is created |
| `updated_at` | `dateTime` | Set when the record changes |
| `deleted_at` | `dateTime`, nullable | Soft-delete marker |
The computed fields are filled by the Seller module’s `OrderGroupRepository` on every read. See [Computed totals](/platform/order-group/concepts/computed-totals).
### Indexes
The model declares three partial indexes, each limited to rows where `deleted_at IS NULL`:
| Index | Columns | Serves |
| --- | --- | --- |
| `IDX_order_group_cart_id` | `cart_id` | The one-group-per-cart lookup at checkout |
| `IDX_order_group_customer_id_created_at` | `customer_id`, `created_at` | A customer’s order history, newest first |
| `IDX_order_group_created_at` | `created_at` | The default newest-first list |
### Relations
`OrderGroup` has no relations inside the Seller module. It reaches other modules through module links:
| Alias | Target | Cardinality | Link |
| --- | --- | --- | --- |
| `orders` | `Order` (Order module) | One group to many orders | `order_group_order` |
| `cart` | `Cart` (Cart module) | One group to one cart, read-only | `cart_id` field |
See [Links](/platform/order-group/reference/links) for the definitions and `query.graph` examples.
## Mutation types
`@mercurjs/types` exports the input shapes for the generated create and update methods:
| Type | Fields |
| --- | --- |
| `CreateOrderGroupDTO` | `cart_id: string`, `customer_id?: string \| null` |
| `UpdateOrderGroupDTO` | `id: string`, `customer_id?: string`, `cart_id?: string` |
Checkout creates every group through `createOrderGroupStep`. Mercur never updates a group after that.