1.0.0 • Published 2 months ago

salesforce-query-builder v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

SalesForce Query Builder

Installation

    npm i salesforce-query-builder

Simple example of QueryBuilder:

    new SFQuery('Contact')
        .select(['Id', 'Name'])
        .where("Name != null")
        .whereIn('Name', ['Maria', 'Ana'])
        .orderBy('Name', 'DESC')
        .limit(3)
        .build()

    SELECT 
        Id,
        Name 
    FROM Contact 
        WHERE Name != null AND Name IN ('Maria','Ana') 
    ORDER BY Name DESC 
    LIMIT 3    

Relationship example of QueryBuilder:

    new SFQuery('Contact')
        .select(['Id', 'Name','Account__r.Name'])
        .where("Name != null")
        .whereIn('Name', ['Maria', 'Ana'])
        .orderBy('Name', 'DESC')
        .limit(3)
        .build()

    SELECT 
        Id,
        Name,
        Account__r.Name
    FROM Contact 
        WHERE Name != null AND Name IN ('Maria','Ana') 
    ORDER BY Name DESC 
    LIMIT 3

EncodeQueryUrl example of QueryBuilder:

encodeQueryUrl(
    new SFQuery('Contact').select(['Id', 'Name'])
        .where("Name != null")
        .limit(3)
        .build()
)

'query/?q=SELECT+Id,Name+FROM+Contact+WHERE+Name+!=+null+LIMIT+3'

References