QB is a query builder that offers a simple and friendly API to generate most of your SOQL queries
Query builder syntax:
QB.select_x('Name')
.from_x('Account')
SOQL equivalent:
select Name from Account
Query builder syntax:
QB.select_x('Id,Name')
.from_x('Account')
.where_x('Name','=','Acme Corporation')
SOQL equivalent:
select Id,Name from Account where Name='Acme Corporation'
Query builder syntax:
QB.select_x('*')
.from_x('Account')
Query builder syntax:
QB.select_x('*__c')
.from_x('Account')
Query builder syntax:
QB.select_x('Name,Type')
.from_x('Account')
.where_x(QB.field('Name').eq('Acme Corporation'))
.groupby('Type')
.orderby('Name')
.limitTo(1)
.offset(100)
SOQL equivalent:
select Name from Account where Name='Acme Corporation' group by Type order by Name limit 1 offset 100
NOTE: 'select', 'from' and 'where' are all reserved words in apex and can not be used as names of methods, to get around the >suffix '_x' is appended to the reserved words