Skip to content

Commit 2e5bdc2

Browse files
committed
documentation update
1 parent 2925482 commit 2e5bdc2

1 file changed

Lines changed: 72 additions & 41 deletions

File tree

website/architecture/registration.md

Lines changed: 72 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -108,69 +108,100 @@ Records sharing the same characteristics are placed in the same bucket and execu
108108

109109
```apex
110110
new DML()
111-
.toInsert(account1)
112-
.toInsert(account2)
113-
.toUpsert(account3)
114-
.toUpsert(account4)
115-
.toInsert(DML.Record(account5).withRelationship(Account.ParentId, account2))
116-
.toInsert(DML.Record(contact1).withRelationship(Contact.AccountId, account2))
117-
.toInsert(DML.Record(contact2).withRelationship(Contact.AccountId, account3))
118-
.toInsert(opportunity1)
119-
.toInsert(DML.Record(opportunity2).withRelationship(Opportunity.AccountId, account4))
120-
.toInsert(lead1)
121-
.commitWork();
122-
123-
// Result: 7 DML statements executed
111+
.toInsert(account1)
112+
.toUpsert(DML.Record(account2).withRelationship(Account.ParentId, account1))
113+
.toUpsert(DML.Record(account4).withRelationship(Account.ParentId, account2))
114+
.toInsert(DML.Record(account5).withRelationship(Account.ParentId, account2))
115+
.toUpsert(DML.Record(account3).withRelationship(Account.ParentId, account5))
116+
.toInsert(DML.Record(account6).withRelationship(Account.ParentId, account5))
117+
.toInsert(DML.Record(account7).withRelationship(Account.ParentId, account5))
118+
.toInsert(account8)
119+
.toInsert(DML.Record(contact1).withRelationship(Contact.AccountId, account2))
120+
.toInsert(DML.Record(contact2).withRelationship(Contact.AccountId, account3))
121+
.toInsert(DML.Record(contact3).withRelationship(Contact.AccountId, account6))
122+
.toInsert(DML.Record(contact4).withRelationship(Contact.AccountId, account6))
123+
.toInsert(DML.Record(opportunity1).withRelationship(Opportunity.AccountId, account1))
124+
.toInsert(DML.Record(opportunity2).withRelationship(Opportunity.AccountId, account4))
125+
.toInsert(DML.Record(opportunity3).withRelationship(Opportunity.AccountId, account6))
126+
.toInsert(DML.Record(opportunity4).withRelationship(Opportunity.AccountId, account6))
127+
.toInsert(lead1)
128+
.commitWork();
129+
130+
// Result: 12 DML statements executed
124131
```
125132

126133
**Dependency Graph**
127134

128135
```mermaid
129136
graph LR
130-
subgraph "No Dependencies"
131-
account1((account1))
132-
account2((account2))
133-
account3((account3))
134-
account4((account4))
135-
opportunity1((opportunity1))
136-
lead1((lead1))
137-
end
138-
139-
subgraph "With Dependencies"
140-
account5((account5))
141-
contact1((contact1))
142-
contact2((contact2))
143-
opportunity2((opportunity2))
144-
end
145-
137+
account1((account1))
138+
account2((account2))
139+
account3((account3))
140+
account4((account4))
141+
account5((account5))
142+
account6((account6))
143+
account7((account7))
144+
account8((account8))
145+
contact1((contact1))
146+
contact2((contact2))
147+
contact3((contact3))
148+
contact4((contact4))
149+
opportunity1((opportunity1))
150+
opportunity2((opportunity2))
151+
opportunity3((opportunity3))
152+
opportunity4((opportunity4))
153+
lead1((lead1))
154+
155+
account2 -->|ParentId| account1
156+
account4 -->|ParentId| account2
146157
account5 -->|ParentId| account2
158+
account3 -->|ParentId| account5
159+
account6 -->|ParentId| account5
160+
account7 -->|ParentId| account5
147161
contact1 -->|AccountId| account2
148162
contact2 -->|AccountId| account3
163+
contact3 -->|AccountId| account6
164+
contact4 -->|AccountId| account6
165+
opportunity1 -->|AccountId| account1
149166
opportunity2 -->|AccountId| account4
167+
opportunity3 -->|AccountId| account6
168+
opportunity4 -->|AccountId| account6
150169
151170
style account1 fill:#4CAF50,color:#fff
152-
style account2 fill:#4CAF50,color:#fff
153-
style account3 fill:#FF9800,color:#fff
154-
style account4 fill:#FF9800,color:#fff
171+
style account2 fill:#FF9800,color:#fff
172+
style account3 fill:#607D8B,color:#fff
173+
style account4 fill:#795548,color:#fff
155174
style account5 fill:#00BCD4,color:#fff
175+
style account6 fill:#8BC34A,color:#fff
176+
style account7 fill:#8BC34A,color:#fff
177+
style account8 fill:#4CAF50,color:#fff
156178
style contact1 fill:#2196F3,color:#fff
157-
style contact2 fill:#2196F3,color:#fff
179+
style contact2 fill:#009688,color:#fff
180+
style contact3 fill:#009688,color:#fff
181+
style contact4 fill:#009688,color:#fff
158182
style opportunity1 fill:#9C27B0,color:#fff
159183
style opportunity2 fill:#E91E63,color:#fff
184+
style opportunity3 fill:#3F51B5,color:#fff
185+
style opportunity4 fill:#3F51B5,color:#fff
160186
style lead1 fill:#F44336,color:#fff
161187
```
162188

163-
Despite registering 10 records, only **7 DML statements** are executed:
189+
Despite registering 17 records, only **12 DML statements** are executed:
164190

165191
| DML # | Operation | SObject | Records | Reason |
166192
|-------|-----------|---------|---------|--------|
167-
| <span style="display:inline-block;width:12px;height:12px;background:#4CAF50;border-radius:2px"></span> 1 | INSERT | Account | account1, account2 | No dependencies, same bucket |
168-
| <span style="display:inline-block;width:12px;height:12px;background:#FF9800;border-radius:2px"></span> 2 | UPSERT | Account | account3, account4 | No dependencies, different operation type |
169-
| <span style="display:inline-block;width:12px;height:12px;background:#9C27B0;border-radius:2px"></span> 3 | INSERT | Opportunity | opportunity1 | No dependencies |
170-
| <span style="display:inline-block;width:12px;height:12px;background:#F44336;border-radius:2px"></span> 4 | INSERT | Lead | lead1 | No dependencies |
171-
| <span style="display:inline-block;width:12px;height:12px;background:#00BCD4;border-radius:2px"></span> 5 | INSERT | Account | account5 | Depends on account2 (ParentId) |
172-
| <span style="display:inline-block;width:12px;height:12px;background:#2196F3;border-radius:2px"></span> 6 | INSERT | Contact | contact1, contact2 | Depend on account2 and account3 |
173-
| <span style="display:inline-block;width:12px;height:12px;background:#E91E63;border-radius:2px"></span> 7 | INSERT | Opportunity | opportunity2 | Depends on account4 (AccountId) |
193+
| <span style="display:inline-block;width:12px;height:12px;background:#4CAF50;border-radius:2px"></span> 1 | INSERT | Account | account1, account8 | No dependencies, same bucket |
194+
| <span style="display:inline-block;width:12px;height:12px;background:#F44336;border-radius:2px"></span> 2 | INSERT | Lead | lead1 | No dependencies |
195+
| <span style="display:inline-block;width:12px;height:12px;background:#FF9800;border-radius:2px"></span> 3 | UPSERT | Account | account2 | Depends on account1 (ParentId) |
196+
| <span style="display:inline-block;width:12px;height:12px;background:#9C27B0;border-radius:2px"></span> 4 | INSERT | Opportunity | opportunity1 | Depends on account1 (AccountId) |
197+
| <span style="display:inline-block;width:12px;height:12px;background:#795548;border-radius:2px"></span> 5 | UPSERT | Account | account4 | Depends on account2 (ParentId) |
198+
| <span style="display:inline-block;width:12px;height:12px;background:#00BCD4;border-radius:2px"></span> 6 | INSERT | Account | account5 | Depends on account2 (ParentId) |
199+
| <span style="display:inline-block;width:12px;height:12px;background:#2196F3;border-radius:2px"></span> 7 | INSERT | Contact | contact1 | Depends on account2 (AccountId) |
200+
| <span style="display:inline-block;width:12px;height:12px;background:#607D8B;border-radius:2px"></span> 8 | UPSERT | Account | account3 | Depends on account5 (ParentId) |
201+
| <span style="display:inline-block;width:12px;height:12px;background:#8BC34A;border-radius:2px"></span> 9 | INSERT | Account | account6, account7 | Depend on account5 (ParentId), same bucket |
202+
| <span style="display:inline-block;width:12px;height:12px;background:#E91E63;border-radius:2px"></span> 10 | INSERT | Opportunity | opportunity2 | Depends on account4 (AccountId) |
203+
| <span style="display:inline-block;width:12px;height:12px;background:#009688;border-radius:2px"></span> 11 | INSERT | Contact | contact2, contact3, contact4 | Depend on account3 and account6, same bucket |
204+
| <span style="display:inline-block;width:12px;height:12px;background:#3F51B5;border-radius:2px"></span> 12 | INSERT | Opportunity | opportunity3, opportunity4 | Depend on account6 (AccountId), same bucket |
174205

175206
::: tip
176207
No matter how you register records - in any order, across multiple method calls, or with complex relationships - DML Lib guarantees the minimal number of DML statements while respecting all dependencies.

0 commit comments

Comments
 (0)