Skip to content

Commit 98a02da

Browse files
committed
Add the lookup method in documentation
1 parent 8f4ba28 commit 98a02da

File tree

1 file changed

+84
-6
lines changed

1 file changed

+84
-6
lines changed

doc/query-apex/src/pages/docs/Query/condition.md

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ weight: 4
1212

1313
## byId
1414

15-
Add a condition to the query, limiting the sObject to a specific ID or a
15+
Add a condition to the query, filtering the result by a specific ID or a
1616
collection of ID. Alias to `addConditionEq('Id', ...)`
1717

1818
#### public Query byId(Id id)
@@ -55,6 +55,84 @@ Query query =
5555

5656
<article id="2">
5757

58+
## lookup
59+
60+
Add a condition to the query, filtering the result by a foreign key.
61+
62+
#### public Query lookup(String fieldName, Id id)
63+
64+
fieldName: The lookup field name
65+
66+
id: The Id to filter the lookup field
67+
68+
```javascript
69+
70+
Query query =
71+
new Query('Contact').
72+
lookup('AccountId', '001O000000qkv3KIAQ');
73+
74+
```
75+
76+
#### public Query lookup(String fieldName, List\<Id\> idList)
77+
78+
fieldName: The lookup field name
79+
80+
idList: The list of Id to filter the lookup field
81+
82+
```javascript
83+
84+
Query query =
85+
new Query('Contact').
86+
lookup('AccountId', new List<Id>{'001O000000qkv3KIAQ'});
87+
88+
```
89+
90+
#### public Query lookup(String fieldName, Set\<Id\> idSet)
91+
92+
fieldName: The lookup field name
93+
94+
idSet: The Set of Id to filter the lookup field
95+
96+
```javascript
97+
98+
Query query =
99+
new Query('Contact').
100+
lookup('AccountId', new Set<Id>{'001O000000qkv3KIAQ'});
101+
102+
```
103+
104+
#### public Query lookup(String fieldName, SObject sobj)
105+
106+
fieldName: The lookup field name
107+
108+
sobj: The SObject record, whose Id will be taken to filter the lookup field
109+
110+
```javascript
111+
112+
Query query =
113+
new Query('Contact').
114+
lookup('AccountId', new Account(Id = '001O000000qkv3KIAQ'));
115+
116+
```
117+
118+
#### public Query lookup(String fieldName, List\<SObject\> sObjectList)
119+
120+
fieldName: The lookup field name
121+
122+
sObjectList: The list of SObject records, whose Id will be taken to filter the lookup field
123+
124+
```javascript
125+
126+
Query query =
127+
new Query('Contact').
128+
lookup('AccountId', new List<Account>{new Account(Id = '001O000000qkv3KIAQ')});
129+
130+
```
131+
132+
</article>
133+
134+
<article id="3">
135+
58136
## addConditionXX
59137

60138
Add a condition to the query, limiting the sObject. 'XX' can be one of these
@@ -245,7 +323,7 @@ Query query =
245323

246324
</article>
247325

248-
<article id="3">
326+
<article id="4">
249327

250328
## addCondition
251329

@@ -266,7 +344,7 @@ Query q =
266344

267345
</article>
268346

269-
<article id="4">
347+
<article id="5">
270348

271349
## conditionXX
272350

@@ -481,7 +559,7 @@ Query q =
481559

482560
</article>
483561

484-
<article id="5">
562+
<article id="6">
485563

486564
## doAnd
487565

@@ -589,7 +667,7 @@ Query q =
589667

590668
</article>
591669

592-
<article id="6">
670+
<article id="7">
593671

594672
## doOr
595673

@@ -699,7 +777,7 @@ Query q =
699777

700778
</article>
701779

702-
<article id="7">
780+
<article id="8">
703781

704782
## Misc
705783

0 commit comments

Comments
 (0)