Skip to content

Commit 3e46315

Browse files
committed
documentation
Signed-off-by: Piotr PG Gajek <[email protected]>
1 parent 891b966 commit 3e46315

File tree

3 files changed

+106
-2
lines changed

3 files changed

+106
-2
lines changed

force-app/main/default/classes/main/standard-soql/SOQL.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ public virtual inherited sharing class SOQL implements Queryable {
101101
Queryable havingConditionLogic(String havingConditionsOrder);
102102
Queryable anyHavingConditionMatching();
103103
// ORDER BY
104+
Queryable orderBy(SObjectField field);
104105
Queryable orderBy(String field);
105106
Queryable orderBy(String field, String direction);
106-
Queryable orderBy(SObjectField field);
107107
Queryable orderBy(String relationshipName, SObjectField field);
108108
Queryable sortDesc();
109109
Queryable nullsLast();

website/docs/api/standard-soql/soql-filters-group.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ The following are methods for `FilterGroup`.
2424
- [`add(FilterGroup filterGroup)`](#add)
2525
- [`add(Filter filter)`](#add)
2626
- [`add(String dynamicCondition)`](#add)
27+
- [`add(List<Filter> filters)`](#add)
28+
- [`add(List<String> dynamicConditions)`](#add)
2729

2830
[**ORDER**](#order)
2931

@@ -46,6 +48,8 @@ Add a [`SOQL.Filter`](soql-filter.md) or [`SOQL.FilterGroup`](soql-filters-group
4648
FilterGroup add(FilterGroup filterGroup)
4749
FilterGroup add(Filter filter)
4850
FilterGroup add(String dynamicCondition)
51+
FilterGroup add(List<Filter> filters)
52+
FilterGroup add(List<String> dynamicConditions)
4953
```
5054

5155
**Example**
@@ -90,6 +94,30 @@ SOQL.of(Account.SObjectType)
9094
).toList();
9195
```
9296

97+
```apex
98+
// SELECT Id FROM Account WHERE (Name = 'Test' AND BillingCity = 'Krakow')
99+
100+
SOQL.of(Account.SObjectType)
101+
.whereAre(SOQL.FilterGroup
102+
.add(new List<SOQL.Filter> {
103+
SOQL.Filter.with(Account.Name).equal('Test'),
104+
SOQL.Filter.with(Account.BillingCity).equal('Krakow')
105+
})
106+
).toList();
107+
```
108+
109+
```apex
110+
// SELECT Id FROM Account WHERE (Name = 'Test' AND BillingCity = 'Krakow')
111+
112+
SOQL.of(Account.SObjectType)
113+
.whereAre(SOQL.FilterGroup
114+
.add(new List<String> {
115+
'Name = \'Test\'',
116+
'BillingCity = \'Krakow\''
117+
})
118+
).toList();
119+
```
120+
93121
## ORDER
94122
### conditionLogic
95123

website/docs/api/standard-soql/soql-sub.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ The following are methods for `SubQuery`.
3131
- [`with(SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4, SObjectField field5)`](#with-field1---field5)
3232
- [`with(List<SObjectField> fields)`](#with-fields)
3333
- [`with(String relationshipName, Iterable<SObjectField> fields)`](#with-related-fields)
34+
- [`with(String fields)`](#with-string-fields)
3435

3536
[**SUBQUERY**](#sub-query)
3637

@@ -44,6 +45,8 @@ The following are methods for `SubQuery`.
4445
[**ORDER BY**](#order-by)
4546

4647
- [`orderBy(SObjectField field)`](#order-by)
48+
- [`orderBy(String field)`](#order-by-string-fields)
49+
- [`orderBy(String field, String direction)`](#orderby-string-fields-with-direction)
4750
- [`orderBy(String relationshipName, SObjectField field)`](#orderby-related)
4851
- [`sortDesc()`](#sortdesc)
4952
- [`nullsLast()`](#nullslast)
@@ -165,7 +168,6 @@ SOQL.of(Account.SObjectType)
165168
SubQuery with(String relationshipName, Iterable<SObjectField> fields)
166169
```
167170

168-
169171
**Example**
170172

171173
```sql
@@ -184,6 +186,30 @@ SOQL.of(Account.SObjectType)
184186
.toList();
185187
```
186188

189+
### with string fields
190+
191+
**Signature**
192+
193+
```apex
194+
SubQuery with(String fields)
195+
```
196+
197+
**Example**
198+
199+
```sql
200+
SELECT Id, (
201+
SELECT Id, Name, Phone, RecordTypeId, Title, Salutation
202+
FROM Contacts
203+
) FROM Account
204+
```
205+
```apex
206+
SOQL.of(Account.SObjectType)
207+
.with(SOQL.SubQuery.of('Contacts')
208+
.with('Id, Name, Phone, RecordTypeId, Title, Salutation)
209+
)
210+
.toList();
211+
```
212+
187213
## SUB-QUERY
188214
### with subquery
189215

@@ -274,6 +300,56 @@ SOQL.of(Account.SObjectType)
274300
.toList();
275301
```
276302

303+
### orderBy string field
304+
305+
**Signature**
306+
307+
```apex
308+
SubQuery orderBy(String field)
309+
```
310+
311+
**Example**
312+
313+
```sql
314+
SELECT Id, (
315+
SELECT Id
316+
FROM Contacts
317+
ORDER BY Name
318+
) FROM Account
319+
```
320+
```apex
321+
SOQL.of(Account.SObjectType)
322+
.with(SOQL.SubQuery.of('Contacts')
323+
.orderBy('Name')
324+
)
325+
.toList();
326+
```
327+
328+
### orderBy string field with direction
329+
330+
**Signature**
331+
332+
```apex
333+
SubQuery orderBy(String field, String direction)
334+
```
335+
336+
**Example**
337+
338+
```sql
339+
SELECT Id, (
340+
SELECT Id
341+
FROM Contacts
342+
ORDER BY Name DESC
343+
) FROM Account
344+
```
345+
```apex
346+
SOQL.of(Account.SObjectType)
347+
.with(SOQL.SubQuery.of('Contacts')
348+
.orderBy('Name', 'DESC')
349+
)
350+
.toList();
351+
```
352+
277353
### orderBy related
278354

279355
Order SOQL query by parent field.

0 commit comments

Comments
 (0)